common.h 1.6 KB

1234567891011121314151617181920212223
  1. #ifndef _SANDBOX__TEST_COMMON_H_
  2. # define _SANDBOX__TEST_COMMON_H_
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include "sandbox.h"
  6. #define _assertTrue(a) { REGISTER_TYPE _a = (REGISTER_TYPE) a; if(!_a) { fprintf(stderr, "File %s, line %d: fail asserting %lld as true\n", __FILE__, __LINE__, (long long int) _a); return -1; }}
  7. #define _assertNotNull(a) { REGISTER_TYPE _a = (REGISTER_TYPE) a; if(!_a) { fprintf(stderr, "File %s, line %d: fail asserting 0x%llx not null\n", __FILE__, __LINE__, (long long int)_a); return -1; }}
  8. #define _assertNull(a) { REGISTER_TYPE _a = (REGISTER_TYPE) a; if(_a) { fprintf(stderr, "File %s, line %d: fail asserting 0x%llx null\n", __FILE__, __LINE__, (long long int) _a); return -1; }}
  9. #define _assertEqual(a, b) { REGISTER_TYPE _a = (REGISTER_TYPE) a; REGISTER_TYPE _b = (REGISTER_TYPE) b; if(_a != _b) { fprintf(stderr, "File %s, line %d: fail asserting %lld equals %lld\n", __FILE__, __LINE__, (long long int) _a, (long long int) _b); return -1; }}
  10. #define _assertDiff(a, b) { REGISTER_TYPE _a = (REGISTER_TYPE) a; REGISTER_TYPE _b = (REGISTER_TYPE) b; if(_a == _b) { fprintf(stderr, "File %s, line %d: fail asserting %lld is different than %lld\n", __FILE__, __LINE__, (long long int) _a, (long long int )_b); return -1; }}
  11. #define _assertStrNEqual(a, b, c) { if (strncmp(a, b, c) != 0) { fprintf(stderr, "File %s, line %d: fail asserting %s match expected string %s\n", __FILE__, __LINE__, a, b); return -1; }}
  12. void tests_init_env(struct s_sandboxenv *env, t_param *params);
  13. void tests_release_env(struct s_sandboxenv *env, t_param *params);
  14. #endif /* _SANDBOX__TEST_COMMON_H_ */