forked from acouzens/open5gs
ASN test code is added initially
This commit is contained in:
parent
3379440df8
commit
9640a8a0fe
|
@ -256,6 +256,7 @@ AC_CONFIG_FILES([lib/core/test/Makefile])
|
|||
AC_CONFIG_FILES([lib/core/Makefile])
|
||||
AC_CONFIG_FILES([lib/logger/Makefile])
|
||||
AC_CONFIG_FILES([lib/asn/asn1c/Makefile])
|
||||
AC_CONFIG_FILES([lib/asn/test/Makefile])
|
||||
AC_CONFIG_FILES([lib/asn/Makefile])
|
||||
AC_CONFIG_FILES([src/Makefile])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = asn1c
|
||||
SUBDIRS = asn1c test
|
||||
|
||||
noinst_LTLIBRARIES = libasn.la
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
bin_PROGRAMS = testasn
|
||||
|
||||
testasn_SOURCES = \
|
||||
abts.h abts_tests.h testutil.h \
|
||||
abts.c testutil.c \
|
||||
s1ap_test.c
|
||||
|
||||
testasn_LDADD = \
|
||||
$(top_srcdir)/lib/core/src/libcore.la \
|
||||
$(top_srcdir)/lib/asn/asn1c/libasn1c.la \
|
||||
$(top_srcdir)/lib/asn/libasn.la \
|
||||
-lpthread -lsctp
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/lib/core/include/arch/@OSDIR@ \
|
||||
-I$(top_srcdir)/lib/core/include \
|
||||
-I$(top_srcdir)/lib/asn/asn1c \
|
||||
-I$(top_srcdir)/lib/asn
|
||||
|
||||
AM_CFLAGS = \
|
||||
-Wall -Werror @OSCFLAGS@ \
|
||||
-Wno-unused-function
|
||||
|
||||
TESTS = testasn
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MOSTLYCLEANFILES = core *.stackdump
|
|
@ -0,0 +1,458 @@
|
|||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "abts.h"
|
||||
#include "abts_tests.h"
|
||||
#include "testutil.h"
|
||||
|
||||
#define ABTS_STAT_SIZE 6
|
||||
static char status[ABTS_STAT_SIZE] = {'|', '/', '-', '|', '\\', '-'};
|
||||
static int curr_char;
|
||||
static int verbose = 1;
|
||||
static int exclude = 0;
|
||||
static int quiet = 0;
|
||||
static int list_tests = 0;
|
||||
|
||||
const char **testlist = NULL;
|
||||
|
||||
static int find_test_name(const char *testname) {
|
||||
int i;
|
||||
for (i = 0; testlist[i] != NULL; i++) {
|
||||
if (!strcmp(testlist[i], testname)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Determine if the test should be run at all */
|
||||
static int should_test_run(const char *testname) {
|
||||
int found = 0;
|
||||
if (list_tests == 1) {
|
||||
return 0;
|
||||
}
|
||||
if (testlist == NULL) {
|
||||
return 1;
|
||||
}
|
||||
found = find_test_name(testname);
|
||||
if ((found && !exclude) || (!found && exclude)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void reset_status(void)
|
||||
{
|
||||
curr_char = 0;
|
||||
}
|
||||
|
||||
static void update_status(void)
|
||||
{
|
||||
if (!quiet) {
|
||||
curr_char = (curr_char + 1) % ABTS_STAT_SIZE;
|
||||
fprintf(stdout, "\b%c", status[curr_char]);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
static void end_suite(abts_suite *suite)
|
||||
{
|
||||
if (suite != NULL) {
|
||||
sub_suite *last = suite->tail;
|
||||
if (!quiet) {
|
||||
fprintf(stdout, "\b");
|
||||
fflush(stdout);
|
||||
}
|
||||
if (last->failed == 0) {
|
||||
fprintf(stdout, "SUCCESS\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "FAILED %d of %d\n", last->failed, last->num_test);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
|
||||
{
|
||||
sub_suite *subsuite;
|
||||
char *p;
|
||||
const char *suite_name;
|
||||
curr_char = 0;
|
||||
|
||||
/* Only end the suite if we actually ran it */
|
||||
if (suite && suite->tail &&!suite->tail->not_run) {
|
||||
end_suite(suite);
|
||||
}
|
||||
|
||||
subsuite = malloc(sizeof(*subsuite));
|
||||
subsuite->num_test = 0;
|
||||
subsuite->failed = 0;
|
||||
subsuite->next = NULL;
|
||||
/* suite_name_full may be an absolute path depending on __FILE__
|
||||
* expansion */
|
||||
suite_name = strrchr(suite_name_full, '/');
|
||||
if (suite_name) {
|
||||
suite_name++;
|
||||
} else {
|
||||
suite_name = suite_name_full;
|
||||
}
|
||||
p = strrchr(suite_name, '.');
|
||||
if (p) {
|
||||
subsuite->name = memcpy(calloc(p - suite_name + 1, 1),
|
||||
suite_name, p - suite_name);
|
||||
}
|
||||
else {
|
||||
subsuite->name = suite_name;
|
||||
}
|
||||
|
||||
if (list_tests) {
|
||||
fprintf(stdout, "%s\n", subsuite->name);
|
||||
}
|
||||
|
||||
subsuite->not_run = 0;
|
||||
|
||||
if (suite == NULL) {
|
||||
suite = malloc(sizeof(*suite));
|
||||
suite->head = subsuite;
|
||||
suite->tail = subsuite;
|
||||
}
|
||||
else {
|
||||
suite->tail->next = subsuite;
|
||||
suite->tail = subsuite;
|
||||
}
|
||||
|
||||
if (!should_test_run(subsuite->name)) {
|
||||
subsuite->not_run = 1;
|
||||
return suite;
|
||||
}
|
||||
|
||||
reset_status();
|
||||
fprintf(stdout, "%-20s: ", subsuite->name);
|
||||
update_status();
|
||||
fflush(stdout);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
void abts_run_test(abts_suite *ts, test_func f, void *value)
|
||||
{
|
||||
abts_case tc;
|
||||
sub_suite *ss;
|
||||
|
||||
if (!should_test_run(ts->tail->name)) {
|
||||
return;
|
||||
}
|
||||
ss = ts->tail;
|
||||
|
||||
tc.failed = 0;
|
||||
tc.suite = ss;
|
||||
|
||||
ss->num_test++;
|
||||
update_status();
|
||||
|
||||
f(&tc, value);
|
||||
|
||||
if (tc.failed) {
|
||||
ss->failed++;
|
||||
}
|
||||
}
|
||||
|
||||
static int report(abts_suite *suite)
|
||||
{
|
||||
int count = 0;
|
||||
sub_suite *dptr;
|
||||
|
||||
if (suite && suite->tail &&!suite->tail->not_run) {
|
||||
end_suite(suite);
|
||||
}
|
||||
|
||||
for (dptr = suite->head; dptr; dptr = dptr->next) {
|
||||
count += dptr->failed;
|
||||
}
|
||||
|
||||
if (list_tests) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
printf("All tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dptr = suite->head;
|
||||
fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests");
|
||||
fprintf(stdout, "===================================================\n");
|
||||
while (dptr != NULL) {
|
||||
if (dptr->failed != 0) {
|
||||
float percent = ((float)dptr->failed / (float)dptr->num_test);
|
||||
fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name,
|
||||
dptr->num_test, dptr->failed, percent * 100);
|
||||
}
|
||||
dptr = dptr->next;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void abts_log_message(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
update_status();
|
||||
|
||||
if (verbose) {
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (expected == actual) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (expected != actual) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (expected == actual) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
/* Note that the comparison is type-exact, reporting must be a best-fit */
|
||||
fprintf(stderr, "Line %d: expected %lu, but saw %lu\n", lineno,
|
||||
(unsigned long)expected, (unsigned long)actual);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (!expected && !actual) return;
|
||||
if (expected && actual)
|
||||
if (!strcmp(expected, actual)) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
|
||||
size_t n, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (!strncmp(expected, actual, n)) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_ptr_null(abts_case *tc, const void *ptr, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (ptr == NULL) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: Expected NULL, but saw <%p>\n", lineno, ptr);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (ptr != NULL) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: Expected not NULL, but saw <%p>\n", lineno, ptr);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (expected == actual) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: expected <%p>, but saw <%p>\n", lineno, expected, actual);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_fail(abts_case *tc, const char *message, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: %s\n", lineno, message);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_assert(abts_case *tc, const char *message, int condition, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (condition) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: %s\n", lineno, message);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_true(abts_case *tc, int condition, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (condition) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: Condition is false, but expected true\n", lineno);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_false(abts_case *tc, int condition, int lineno)
|
||||
{
|
||||
update_status();
|
||||
if (tc->failed) return;
|
||||
|
||||
if (!condition) return;
|
||||
|
||||
tc->failed = TRUE;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: Condition is true, but expected false\n", lineno);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void abts_not_impl(abts_case *tc, const char *message, int lineno)
|
||||
{
|
||||
update_status();
|
||||
|
||||
tc->suite->not_impl++;
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Line %d: %s\n", lineno, message);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char *const argv[]) {
|
||||
int i;
|
||||
int rv;
|
||||
int list_provided = 0;
|
||||
abts_suite *suite = NULL;
|
||||
|
||||
test_initialize();
|
||||
|
||||
quiet = !isatty(STDOUT_FILENO);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-v")) {
|
||||
verbose = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-x")) {
|
||||
exclude = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-l")) {
|
||||
list_tests = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[i], "-q")) {
|
||||
quiet = 1;
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
list_provided = 1;
|
||||
}
|
||||
|
||||
if (list_provided) {
|
||||
/* Waste a little space here, because it is easier than counting the
|
||||
* number of tests listed. Besides it is at most three char *.
|
||||
*/
|
||||
testlist = calloc(argc + 1, sizeof(char *));
|
||||
for (i = 1; i < argc; i++) {
|
||||
testlist[i - 1] = argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < (sizeof(alltests) / sizeof(struct testlist *)); i++) {
|
||||
suite = alltests[i].func(suite);
|
||||
}
|
||||
|
||||
rv = report(suite);
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef ABTS_H
|
||||
#define ABTS_H
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
struct sub_suite {
|
||||
const char *name;
|
||||
int num_test;
|
||||
int failed;
|
||||
int not_run;
|
||||
int not_impl;
|
||||
struct sub_suite *next;
|
||||
};
|
||||
typedef struct sub_suite sub_suite;
|
||||
|
||||
struct abts_suite {
|
||||
sub_suite *head;
|
||||
sub_suite *tail;
|
||||
};
|
||||
typedef struct abts_suite abts_suite;
|
||||
|
||||
struct abts_case {
|
||||
int failed;
|
||||
sub_suite *suite;
|
||||
};
|
||||
typedef struct abts_case abts_case;
|
||||
|
||||
typedef void (*test_func)(abts_case *tc, void *data);
|
||||
|
||||
#define ADD_SUITE(suite) abts_add_suite(suite, __FILE__);
|
||||
|
||||
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name);
|
||||
void abts_run_test(abts_suite *ts, test_func f, void *value);
|
||||
void abts_log_message(const char *fmt, ...);
|
||||
|
||||
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno);
|
||||
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno);
|
||||
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno);
|
||||
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
|
||||
size_t n, int lineno);
|
||||
void abts_ptr_null(abts_case *tc, const void *ptr, int lineno);
|
||||
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno);
|
||||
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
|
||||
void abts_true(abts_case *tc, int condition, int lineno);
|
||||
void abts_false(abts_case *tc, int condition, int lineno);
|
||||
void abts_fail(abts_case *tc, const char *message, int lineno);
|
||||
void abts_not_impl(abts_case *tc, const char *message, int lineno);
|
||||
void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
|
||||
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno);
|
||||
|
||||
/* Convenience macros. Ryan hates these! */
|
||||
#define ABTS_INT_EQUAL(a, b, c) abts_int_equal(a, b, c, __LINE__)
|
||||
#define ABTS_INT_NEQUAL(a, b, c) abts_int_nequal(a, b, c, __LINE__)
|
||||
#define ABTS_STR_EQUAL(a, b, c) abts_str_equal(a, b, c, __LINE__)
|
||||
#define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__)
|
||||
#define ABTS_PTR_NULL(a, b) abts_ptr_null(a, b, __LINE__)
|
||||
#define ABTS_PTR_NOTNULL(a, b) abts_ptr_notnull(a, b, __LINE__)
|
||||
#define ABTS_PTR_EQUAL(a, b, c) abts_ptr_equal(a, b, c, __LINE__)
|
||||
#define ABTS_TRUE(a, b) abts_true(a, b, __LINE__);
|
||||
#define ABTS_FALSE(a, b) abts_false(a, b, __LINE__);
|
||||
#define ABTS_FAIL(a, b) abts_fail(a, b, __LINE__);
|
||||
#define ABTS_NOT_IMPL(a, b) abts_not_impl(a, b, __LINE__);
|
||||
#define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__);
|
||||
|
||||
#define ABTS_SIZE_EQUAL(a, b, c) abts_size_equal(a, b, c, __LINE__)
|
||||
|
||||
|
||||
abts_suite *run_tests(abts_suite *suite);
|
||||
abts_suite *run_tests1(abts_suite *suite);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef APR_TEST_INCLUDES
|
||||
#define APR_TEST_INCLUDES
|
||||
|
||||
#include "abts.h"
|
||||
#include "testutil.h"
|
||||
|
||||
const struct testlist {
|
||||
abts_suite *(*func)(abts_suite *suite);
|
||||
} alltests[] = {
|
||||
{test_s1ap},
|
||||
};
|
||||
|
||||
#endif /* APR_TEST_INCLUDES */
|
|
@ -0,0 +1,20 @@
|
|||
#include "core.h"
|
||||
#include "core_errno.h"
|
||||
#include "core_general.h"
|
||||
#include "core_debug.h"
|
||||
#include "core_pkbuf.h"
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
static void s1ap_test1(abts_case *tc, void *data)
|
||||
{
|
||||
}
|
||||
|
||||
abts_suite *test_s1ap(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, s1ap_test1, NULL);
|
||||
|
||||
return suite;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core.h"
|
||||
#include "abts.h"
|
||||
#include "testutil.h"
|
||||
|
||||
void core_assert_ok(abts_case* tc, const char* context, status_t rv,
|
||||
int lineno)
|
||||
{
|
||||
if (rv == CORE_ENOTIMPL)
|
||||
{
|
||||
abts_not_impl(tc, context, lineno);
|
||||
} else if (rv != CORE_OK)
|
||||
{
|
||||
char buf[STRING_MAX], ebuf[128];
|
||||
sprintf(buf, "%s (%d): %s\n", context, rv,
|
||||
core_strerror(rv, ebuf, sizeof ebuf));
|
||||
abts_fail(tc, buf, lineno);
|
||||
}
|
||||
}
|
||||
|
||||
void test_initialize(void)
|
||||
{
|
||||
core_initialize();
|
||||
atexit(core_terminate);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "core_general.h"
|
||||
#include "abts.h"
|
||||
|
||||
#ifndef __APR_TEST_UTIL__
|
||||
#define __APR_TEST_UTIL__
|
||||
|
||||
/* XXX: FIXME - these all should become much more utilitarian
|
||||
* and part of core, itself
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef BINPATH
|
||||
#define TESTBINPATH APR_STRINGIFY(BINPATH) "/"
|
||||
#else
|
||||
#define TESTBINPATH ""
|
||||
#endif
|
||||
#else
|
||||
#define TESTBINPATH "./"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define EXTENSION ".exe"
|
||||
#elif NETWARE
|
||||
#define EXTENSION ".nlm"
|
||||
#else
|
||||
#define EXTENSION
|
||||
#endif
|
||||
|
||||
#define STRING_MAX 8096
|
||||
|
||||
/* Some simple functions to make the test apps easier to write and
|
||||
* a bit more consistent...
|
||||
*/
|
||||
|
||||
/* Assert that RV is an CORE_OK value; else fail giving strerror
|
||||
* for RV and CONTEXT message. */
|
||||
void core_assert_ok(abts_case* tc, const char *context,
|
||||
status_t rv, int lineno);
|
||||
#define CORE_ASSERT_OK(tc, ctxt, rv) \
|
||||
core_assert_ok(tc, ctxt, rv, __LINE__)
|
||||
|
||||
void test_initialize(void);
|
||||
|
||||
abts_suite *test_s1ap(abts_suite *suite);
|
||||
|
||||
#endif /* CORE_TEST_INCLUDES */
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
bin_PROGRAMS = testcore
|
||||
|
||||
nodist_testcore_SOURCES = \
|
||||
testcore_SOURCES = \
|
||||
abts.c testds.c testfsm.c testnetlib.c testthread.c testtlv.c \
|
||||
testaes.c testfile.c testlock.c testsha.c testtime.c testutil.c \
|
||||
testdir.c testfilecopy.c testmsgq.c testsleep.c testtimer.c \
|
||||
|
|
Loading…
Reference in New Issue