Skip to content
Snippets Groups Projects
  1. Oct 13, 2014
  2. Oct 12, 2014
  3. Sep 29, 2014
  4. Sep 17, 2014
  5. Sep 16, 2014
    • Nick Mathewson's avatar
    • Nick Mathewson's avatar
      Remove the legacy_test_helper and legacy_setup wrappers · a6627fdb
      Nick Mathewson authored
      These wrappers went into place when the default type for our unit
      test functions changed from "void fn(void)" to "void fn(void *arg)".
      
      To generate this patch, I did the same hokey-pokey as before with
      replacing all operators used as macro arguments, then I ran a
      coccinelle script, then I ran perl script to fix up everything that
      used legacy_test_helper, then I manually removed the
      legacy_test_helper functions, then I ran a final perl script to put
      the operators back how they were.
      
      ==============================
       #!/usr/bin/perl -w -i -p
      
      s/==,/_X_EQ_,/g;
      s/!=,/_X_NE_,/g;
      s/<,/_X_LT_,/g;
      s/>,/_X_GT_,/g;
      s/>=,/_X_GEQ_,/g;
      s/<=,/_X_LEQ_,/g;
      
      --------------------
      
      @@
      identifier func =~ "test_.*$";
      statement S, S2;
      @@
       static void func (
      -void
      +void *arg
       )
       {
       ... when != S2
      +(void) arg;
       S
       ...
       }
      
      --------------------
       #!/usr/bin/perl -w -i -p
      
      s/, *legacy_test_helper, *([^,]+), *\&legacy_setup, *([^\}]+) *}/, $2, $1, NULL, NULL }/g;
      
      --------------------
       #!/usr/bin/perl -w -i -p
      
      s/_X_NEQ_/!=/g;
      s/_X_NE_/!=/g;
      s/_X_EQ_/==/g;
      s/_X_GT_/>/g;
      s/_X_LT_/</g;
      s/_X_GEQ_/>=/g;
      s/_X_LEQ_/<=/g;
      
      --------------------
      a6627fdb
    • Nick Mathewson's avatar
      34bf9b36
    • Nick Mathewson's avatar
      Replace the remaining test_n?eq_ptr calls · 1146a6a1
      Nick Mathewson authored
      1146a6a1
    • Nick Mathewson's avatar
      Use coccinelle scripts to clean up our unit tests · 02438957
      Nick Mathewson authored
      This should get rid of most of the users of the old test_*
      functions.  Some are in macros and will need manual cleanup, though.
      
      This patch is for 13119, and was automatically generated with these
      scripts.  The perl scripts are there because coccinelle hates
      operators as macro arguments.
      
      ------------------------------
      
      s/==,/_X_EQ_,/g;
      s/!=,/_X_NE_,/g;
      s/<,/_X_LT_,/g;
      s/>,/_X_GT_,/g;
      s/>=,/_X_GEQ_,/g;
      s/<=,/_X_LEQ_,/g;
      
      ------------------------------
      @@
      expression a;
      identifier func;
      @@
       func (...) {
      <...
      -test_fail_msg
      +TT_DIE
       (
      +(
       a
      +)
       )
       ...>
       }
      
      @@
      identifier func;
      @@
       func (...) {
      <...
      -test_fail()
      +TT_DIE(("Assertion failed."))
       ...>
       }
      
      @@
      expression a;
      identifier func;
      @@
       func (...) {
      <...
      -test_assert
      +tt_assert
      	(a)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_eq
      +tt_int_op
       (a,
      +_X_EQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_neq
      +tt_int_op
       (a,
      +_X_NEQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_streq
      +tt_str_op
       (a,
      +_X_EQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_strneq
      +tt_str_op
       (a,
      +_X_NEQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func (...) {
      <...
      -test_eq_ptr
      +tt_ptr_op
       (a,
      +_X_EQ_,
        b)
       ...>
       }
      
      @@
      expression a, b;
      identifier func;
      @@
       func() {
      <...
      -test_neq_ptr
      +tt_ptr_op
       (a,
      +_X_NEQ_,
        b)
       ...>
       }
      
      @@
      expression a, b, len;
      identifier func;
      @@
       func (...) {
      <...
      -test_memeq
      +tt_mem_op
       (a,
      +_X_EQ_,
        b, len)
       ...>
       }
      
      @@
      expression a, b, len;
      identifier func;
      @@
       func (...) {
      <...
      -test_memneq
      +tt_mem_op
       (a,
      +_X_NEQ_,
        b, len)
       ...>
       }
      
      ------------------------------
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a == b
      +a, _X_EQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a != b
      +a, _X_NEQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a >= b
      +a, _X_GEQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a <= b
      +a, _X_LEQ_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a > b
      +a, _X_GT_, b
       )
       ...>
      }
      
      @@
      char a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_int_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      unsigned int a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      @@
      unsigned long a, b;
      identifier func;
      @@
       func (...) {
      <...
      -tt_assert
      +tt_uint_op
       (
      -a < b
      +a, _X_LT_, b
       )
       ...>
      }
      
      ------------------------------
      
      s/_X_NEQ_/!=/g;
      s/_X_NE_/!=/g;
      s/_X_EQ_/==/g;
      s/_X_GT_/>/g;
      s/_X_LT_/</g;
      s/_X_GEQ_/>=/g;
      s/_X_LEQ_/<=/g;
      
      s/test_mem_op\(/tt_mem_op\(/g;
      02438957
  6. Sep 15, 2014
  7. Sep 11, 2014
  8. Sep 02, 2014
  9. Aug 13, 2014
  10. Jul 28, 2014
  11. Jul 16, 2014
    • Nick Mathewson's avatar
      Add a tor_ftruncate to replace ftruncate. · 867f5e6a
      Nick Mathewson authored
      (Windows doesn't have ftruncate, and some ftruncates do not move the
      file pointer to the start of the file.)
      867f5e6a
    • cypherpunks's avatar
      Fixed fgets_eagain unit test. · 61507417
      cypherpunks authored and Nick Mathewson's avatar Nick Mathewson committed
      On a non-blocking pipe fgets sets EAGAIN when it encounters partial lines. No
      error is set on full lines or EOF. EOF is reached when the writing end of the
      pipe is closed. Partial lines and full lines are both returned by fgets, EOF
      results in NULL.
      
      Mention of this behaviour can be found in #1903 and #2045.
      61507417
  12. Jun 20, 2014
    • Nick Mathewson's avatar
      Thread support is now required · 58f42007
      Nick Mathewson authored
      Long ago we supported systems where there was no support for
      threads, or where the threading library was broken. We shouldn't
      have do that any more: on every OS that matters, threads exist, and
      the OS supports running threads across multiple CPUs.
      
      This resolves tickets 9495 and 12439.  It's a prerequisite to making
      our workqueue code work better, since sensible workqueue
      implementations don't split across multiple processes.
      58f42007
  13. Jun 14, 2014
  14. May 13, 2014
  15. May 12, 2014
  16. May 08, 2014
  17. Apr 26, 2014
  18. Apr 24, 2014
  19. Apr 08, 2014
Loading