1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** @brief Lua sandbox unit tests @file */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <luasandbox/heka/sandbox.h>
#include <luasandbox/test/mu_test.h>
#include <luasandbox/test/sandbox.h>
#include "test_module.h"
char *e = NULL;
static const char *test_cfg =
"memory_limit = 0\n"
"instruction_limit = 0\n"
"output_limit = 0\n"
TEST_MODULE_PATH
;
static char* test_core()
{
lsb_lua_sandbox *sb = lsb_create(NULL, "test.lua", test_cfg, NULL);
mu_assert(sb, "lsb_create() received: NULL");
lsb_err_value ret = lsb_init(sb, NULL);
mu_assert(!ret, "lsb_init() received: %s %s", ret, lsb_get_error(sb));
e = lsb_destroy(sb);
mu_assert(!e, "lsb_destroy() received: %s", e);
return NULL;
}
static char* all_tests()
{
mu_run_test(test_core);
return NULL;
}
int main()
{
char *result = all_tests();
if (result) {
printf("%s\n", result);
} else {
printf("ALL TESTS PASSED\n");
}
printf("Tests run: %d\n", mu_tests_run);
free(e);
return result != NULL;
}
|