From 3baeb11a8fbcfcdbc31976d421f17b85503b3ecd Mon Sep 17 00:00:00 2001 From: WuKong Date: Fri, 4 Sep 2015 09:25:34 +0200 Subject: init attribute-based encryption Change-Id: Iba1a3d722110abf747a0fba366f3ebc911d25b25 --- moon-abe/pbc-0.5.14/include/pbc_test.h | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 moon-abe/pbc-0.5.14/include/pbc_test.h (limited to 'moon-abe/pbc-0.5.14/include/pbc_test.h') diff --git a/moon-abe/pbc-0.5.14/include/pbc_test.h b/moon-abe/pbc-0.5.14/include/pbc_test.h new file mode 100644 index 00000000..35d6f754 --- /dev/null +++ b/moon-abe/pbc-0.5.14/include/pbc_test.h @@ -0,0 +1,42 @@ +// Useful for tests. + +#ifndef __PBC_TEST_H__ +#define __PBC_TEST_H__ + +/*@manual test +Initializes pairing from file specified as first argument, or from standard +input if there is no first argument. +*/ +static inline void pbc_demo_pairing_init(pairing_t pairing, int argc, char **argv) { + char s[16384]; + FILE *fp = stdin; + + if (argc > 1) { + fp = fopen(argv[1], "r"); + if (!fp) pbc_die("error opening %s", argv[1]); + } + size_t count = fread(s, 1, 16384, fp); + if (!count) pbc_die("input error"); + fclose(fp); + + if (pairing_init_set_buf(pairing, s, count)) pbc_die("pairing init failed"); +} + +/*@manual test +Returns seconds elapsed since the first call to this function. +Returns 0 the first time. +*/ +double pbc_get_time(void); + +/*@manual test +Macro: if `condition` evaluates to 0 then print an error. +*/ +#define EXPECT(condition) \ + if (condition); else pbc_err_count++, fprintf(stderr, "\n*** FAIL ***\n %s:%d: %s\n\n", __FILE__, __LINE__, #condition) + +/*@manual test +Total number of failed EXPECT checks. +*/ +int pbc_err_count; + +#endif //__PBC_TEST_H__ -- cgit 1.2.3-korg