From 2a96208cb00220f963e723ae0530492c5c70df27 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Thu, 11 Feb 2010 13:30:32 +0000 Subject: OTP-8335 Even more NIF features --- erts/emulator/test/nif_SUITE_data/tester.c | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 erts/emulator/test/nif_SUITE_data/tester.c (limited to 'erts/emulator/test/nif_SUITE_data/tester.c') diff --git a/erts/emulator/test/nif_SUITE_data/tester.c b/erts/emulator/test/nif_SUITE_data/tester.c new file mode 100644 index 0000000000..08466d0f18 --- /dev/null +++ b/erts/emulator/test/nif_SUITE_data/tester.c @@ -0,0 +1,73 @@ +#include "erl_nif.h" + +#include +#include + +void testcase_printf(TestCaseState_t *tcs, char *frmt, ...) +{ + va_list va; + va_start(va, frmt); + vfprintf(stderr, frmt, va); + va_end(va); + fprintf(stderr, "\r"); +} + +void testcase_succeeded(TestCaseState_t *tcs, char *frmt, ...) +{ +} + +void testcase_skipped(TestCaseState_t *tcs, char *frmt, ...) +{ +} + +void testcase_failed(TestCaseState_t *tcs, char *frmt, ...) +{ + va_list va; + va_start(va, frmt); + vfprintf(stderr, frmt, va); + va_end(va); + abort(); +} + +int testcase_assertion_failed(TestCaseState_t *tcs, char *file, int line, + char *assertion) +{ + testcase_failed(tcs, "ASSERTION '%s' FAILED at %s:%d\r\n", + assertion, file, line); + abort(); + return 0; /*?*/ +} + +void *testcase_alloc(size_t size) +{ + return malloc(size); +} +void *testcase_realloc(void *ptr, size_t size) +{ + return realloc(ptr, size); +} +void testcase_free(void *ptr) +{ + free(ptr); +} + +void testcase_run(TestCaseState_t *tcs); + +static int reload(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) +{ + return 0; +} + +static ERL_NIF_TERM run(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + testcase_run(NULL); + return enif_make_atom(env, "ok"); +} + +static ErlNifFunc nif_funcs[] = +{ + {"run", 0, run} +}; + +ERL_NIF_INIT(tester,nif_funcs,NULL,reload,NULL,NULL) + -- cgit v1.2.3