mirror of https://github.com/tailix/libkernaux.git
Use assertions on tests (#73)
This commit is contained in:
parent
2de2bd9679
commit
c99cce166e
|
@ -1,3 +1,7 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <kernaux/assert.h>
|
#include <kernaux/assert.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -5,9 +9,12 @@
|
||||||
|
|
||||||
void example_main();
|
void example_main();
|
||||||
|
|
||||||
static void assert_cb(const char *file, const int line, const char *msg)
|
static void assert_cb(
|
||||||
{
|
const char *const file,
|
||||||
fprintf(stderr, "%s:%i:%s\n", file, line, msg);
|
const int line,
|
||||||
|
const char *const msg
|
||||||
|
) {
|
||||||
|
fprintf(stderr, "%s:%d:%s\n", file, line, msg);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@ if WITH_MULTIBOOT2
|
||||||
noinst_PROGRAMS += multiboot2_header_print1
|
noinst_PROGRAMS += multiboot2_header_print1
|
||||||
multiboot2_header_print1_LDADD = $(top_builddir)/libkernaux.la
|
multiboot2_header_print1_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_header_print1_SOURCES = \
|
multiboot2_header_print1_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
multiboot2_header_print1.c \
|
multiboot2_header_print1.c \
|
||||||
multiboot2_header_example1.h
|
multiboot2_header_example1.h
|
||||||
endif
|
endif
|
||||||
|
@ -26,8 +25,7 @@ if WITH_MULTIBOOT2
|
||||||
noinst_PROGRAMS += multiboot2_header_print2
|
noinst_PROGRAMS += multiboot2_header_print2
|
||||||
multiboot2_header_print2_LDADD = $(top_builddir)/libkernaux.la
|
multiboot2_header_print2_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_header_print2_SOURCES = \
|
multiboot2_header_print2_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
multiboot2_header_print2.c \
|
multiboot2_header_print2.c \
|
||||||
multiboot2_header_example2.h
|
multiboot2_header_example2.h
|
||||||
endif
|
endif
|
||||||
|
@ -40,8 +38,7 @@ if WITH_MULTIBOOT2
|
||||||
noinst_PROGRAMS += multiboot2_info_print1
|
noinst_PROGRAMS += multiboot2_info_print1
|
||||||
multiboot2_info_print1_LDADD = $(top_builddir)/libkernaux.la
|
multiboot2_info_print1_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_info_print1_SOURCES = \
|
multiboot2_info_print1_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
multiboot2_info_print1.c \
|
multiboot2_info_print1.c \
|
||||||
multiboot2_info_example1.h
|
multiboot2_info_example1.h
|
||||||
endif
|
endif
|
||||||
|
@ -54,8 +51,7 @@ if WITH_MULTIBOOT2
|
||||||
noinst_PROGRAMS += multiboot2_info_print2
|
noinst_PROGRAMS += multiboot2_info_print2
|
||||||
multiboot2_info_print2_LDADD = $(top_builddir)/libkernaux.la
|
multiboot2_info_print2_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_info_print2_SOURCES = \
|
multiboot2_info_print2_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
multiboot2_info_print2.c \
|
multiboot2_info_print2.c \
|
||||||
multiboot2_info_example2.h
|
multiboot2_info_example2.h
|
||||||
endif
|
endif
|
||||||
|
@ -68,8 +64,7 @@ if WITH_ALLOC
|
||||||
TESTS += test_alloc
|
TESTS += test_alloc
|
||||||
test_alloc_LDADD = $(top_builddir)/libkernaux.la
|
test_alloc_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_alloc_SOURCES = \
|
test_alloc_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_alloc.c
|
test_alloc.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -81,8 +76,7 @@ if WITH_CMDLINE
|
||||||
TESTS += test_cmdline
|
TESTS += test_cmdline
|
||||||
test_cmdline_LDADD = $(top_builddir)/libkernaux.la
|
test_cmdline_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_cmdline_SOURCES = \
|
test_cmdline_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_cmdline.c
|
test_cmdline.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -95,8 +89,7 @@ if WITH_CMDLINE
|
||||||
TESTS += test_cmdline_gen
|
TESTS += test_cmdline_gen
|
||||||
test_cmdline_gen_LDADD = $(top_builddir)/libkernaux.la
|
test_cmdline_gen_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_cmdline_gen_SOURCES = \
|
test_cmdline_gen_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_cmdline_gen.c \
|
test_cmdline_gen.c \
|
||||||
cmdline_gen.py \
|
cmdline_gen.py \
|
||||||
cmdline_gen.jinja \
|
cmdline_gen.jinja \
|
||||||
|
@ -117,8 +110,7 @@ if WITH_ELF
|
||||||
TESTS += test_elf
|
TESTS += test_elf
|
||||||
test_elf_LDADD = $(top_builddir)/libkernaux.la
|
test_elf_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_elf_SOURCES = \
|
test_elf_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_elf.c
|
test_elf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -130,8 +122,7 @@ if WITH_MBR
|
||||||
TESTS += test_mbr
|
TESTS += test_mbr
|
||||||
test_mbr_LDADD = $(top_builddir)/libkernaux.la
|
test_mbr_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_mbr_SOURCES = \
|
test_mbr_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_mbr.c
|
test_mbr.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -143,8 +134,7 @@ if WITH_MEMMAP
|
||||||
TESTS += test_memmap
|
TESTS += test_memmap
|
||||||
test_memmap_LDADD = $(top_builddir)/libkernaux.la
|
test_memmap_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_memmap_SOURCES = \
|
test_memmap_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_memmap.c
|
test_memmap.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -156,8 +146,7 @@ if WITH_MULTIBOOT2
|
||||||
TESTS += test_multiboot2_common_packing
|
TESTS += test_multiboot2_common_packing
|
||||||
test_multiboot2_common_packing_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_common_packing_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_common_packing_SOURCES = \
|
test_multiboot2_common_packing_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_common_packing.c \
|
test_multiboot2_common_packing.c \
|
||||||
multiboot2_header_example2.h \
|
multiboot2_header_example2.h \
|
||||||
multiboot2_info_example2.h
|
multiboot2_info_example2.h
|
||||||
|
@ -171,8 +160,7 @@ if WITH_MULTIBOOT2
|
||||||
TESTS += test_multiboot2_header_helpers
|
TESTS += test_multiboot2_header_helpers
|
||||||
test_multiboot2_header_helpers_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_header_helpers_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_header_helpers_SOURCES = \
|
test_multiboot2_header_helpers_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_header_helpers.c \
|
test_multiboot2_header_helpers.c \
|
||||||
multiboot2_header_example1.h \
|
multiboot2_header_example1.h \
|
||||||
multiboot2_header_example2.h
|
multiboot2_header_example2.h
|
||||||
|
@ -189,8 +177,7 @@ test_multiboot2_header_print_DEPENDENCIES = \
|
||||||
multiboot2_header_print2
|
multiboot2_header_print2
|
||||||
test_multiboot2_header_print_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_header_print_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_header_print_SOURCES = \
|
test_multiboot2_header_print_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_header_print.c
|
test_multiboot2_header_print.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -202,8 +189,7 @@ if WITH_MULTIBOOT2
|
||||||
TESTS += test_multiboot2_header_validation
|
TESTS += test_multiboot2_header_validation
|
||||||
test_multiboot2_header_validation_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_header_validation_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_header_validation_SOURCES = \
|
test_multiboot2_header_validation_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_header_validation.c \
|
test_multiboot2_header_validation.c \
|
||||||
multiboot2_header_example1.h \
|
multiboot2_header_example1.h \
|
||||||
multiboot2_header_example2.h
|
multiboot2_header_example2.h
|
||||||
|
@ -217,8 +203,7 @@ if WITH_MULTIBOOT2
|
||||||
TESTS += test_multiboot2_info_helpers
|
TESTS += test_multiboot2_info_helpers
|
||||||
test_multiboot2_info_helpers_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_info_helpers_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_info_helpers_SOURCES = \
|
test_multiboot2_info_helpers_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_info_helpers.c \
|
test_multiboot2_info_helpers.c \
|
||||||
multiboot2_info_example1.h \
|
multiboot2_info_example1.h \
|
||||||
multiboot2_info_example2.h
|
multiboot2_info_example2.h
|
||||||
|
@ -235,8 +220,7 @@ test_multiboot2_info_print_DEPENDENCIES = \
|
||||||
multiboot2_info_print2
|
multiboot2_info_print2
|
||||||
test_multiboot2_info_print_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_info_print_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_info_print_SOURCES = \
|
test_multiboot2_info_print_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_info_print.c
|
test_multiboot2_info_print.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -248,8 +232,7 @@ if WITH_MULTIBOOT2
|
||||||
TESTS += test_multiboot2_info_validation
|
TESTS += test_multiboot2_info_validation
|
||||||
test_multiboot2_info_validation_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_info_validation_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_info_validation_SOURCES = \
|
test_multiboot2_info_validation_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_multiboot2_info_validation.c \
|
test_multiboot2_info_validation.c \
|
||||||
multiboot2_info_example1.h \
|
multiboot2_info_example1.h \
|
||||||
multiboot2_info_example2.h
|
multiboot2_info_example2.h
|
||||||
|
@ -263,8 +246,7 @@ if WITH_NTOA
|
||||||
TESTS += test_ntoa
|
TESTS += test_ntoa
|
||||||
test_ntoa_LDADD = $(top_builddir)/libkernaux.la
|
test_ntoa_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_ntoa_SOURCES = \
|
test_ntoa_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_ntoa.c
|
test_ntoa.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -277,8 +259,7 @@ if WITH_NTOA
|
||||||
TESTS += test_ntoa_assert
|
TESTS += test_ntoa_assert
|
||||||
test_ntoa_assert_LDADD = $(top_builddir)/libkernaux.la
|
test_ntoa_assert_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_ntoa_assert_SOURCES = \
|
test_ntoa_assert_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_ntoa_assert.c
|
test_ntoa_assert.c
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -291,8 +272,7 @@ if WITH_PFA
|
||||||
TESTS += test_pfa
|
TESTS += test_pfa
|
||||||
test_pfa_LDADD = $(top_builddir)/libkernaux.la
|
test_pfa_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_pfa_SOURCES = \
|
test_pfa_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_pfa.c
|
test_pfa.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -305,8 +285,7 @@ if WITH_PFA
|
||||||
TESTS += test_pfa_assert
|
TESTS += test_pfa_assert
|
||||||
test_pfa_assert_LDADD = $(top_builddir)/libkernaux.la
|
test_pfa_assert_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_pfa_assert_SOURCES = \
|
test_pfa_assert_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_pfa_assert.c
|
test_pfa_assert.c
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -320,8 +299,7 @@ if WITH_PRINTF_FMT
|
||||||
TESTS += test_printf_fmt_gen
|
TESTS += test_printf_fmt_gen
|
||||||
test_printf_fmt_gen_LDADD = $(top_builddir)/libkernaux.la
|
test_printf_fmt_gen_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_printf_fmt_gen_SOURCES = \
|
test_printf_fmt_gen_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_printf_fmt_gen.c \
|
test_printf_fmt_gen.c \
|
||||||
printf_fmt_gen.py \
|
printf_fmt_gen.py \
|
||||||
printf_fmt_gen.jinja \
|
printf_fmt_gen.jinja \
|
||||||
|
@ -343,8 +321,7 @@ if WITH_PRINTF
|
||||||
TESTS += test_printf_gen
|
TESTS += test_printf_gen
|
||||||
test_printf_gen_LDADD = $(top_builddir)/libkernaux.la
|
test_printf_gen_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_printf_gen_SOURCES = \
|
test_printf_gen_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_printf_gen.c \
|
test_printf_gen.c \
|
||||||
printf_gen.py \
|
printf_gen.py \
|
||||||
printf_gen.jinja \
|
printf_gen.jinja \
|
||||||
|
@ -366,7 +343,6 @@ if WITH_UNITS
|
||||||
TESTS += test_units_human
|
TESTS += test_units_human
|
||||||
test_units_human_LDADD = $(top_builddir)/libkernaux.la
|
test_units_human_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_units_human_SOURCES = \
|
test_units_human_SOURCES = \
|
||||||
helper.c \
|
main.c \
|
||||||
helper.h \
|
|
||||||
test_units_human.c
|
test_units_human.c
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -24,7 +24,7 @@ static void test(
|
||||||
const char *const *const expected_argv
|
const char *const *const expected_argv
|
||||||
);
|
);
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
{% for case in cases %}
|
{% for case in cases %}
|
||||||
{
|
{
|
||||||
|
@ -58,8 +58,6 @@ int main()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test(
|
void test(
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef KERNAUX_INCLUDED_TESTS_HELPER
|
|
||||||
#define KERNAUX_INCLUDED_TESTS_HELPER
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setup_assert_abort();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -7,14 +7,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void assert_cb_abort(const char *file, int line, const char *msg);
|
void test_main(int argc, char **argv);
|
||||||
|
|
||||||
void setup_assert_abort()
|
static void assert_cb(
|
||||||
{
|
|
||||||
kernaux_assert_cb = assert_cb_abort;
|
|
||||||
}
|
|
||||||
|
|
||||||
void assert_cb_abort(
|
|
||||||
const char *const file,
|
const char *const file,
|
||||||
const int line,
|
const int line,
|
||||||
const char *const msg
|
const char *const msg
|
||||||
|
@ -22,3 +17,10 @@ void assert_cb_abort(
|
||||||
fprintf(stderr, "%s:%d:%s\n", file, line, msg);
|
fprintf(stderr, "%s:%d:%s\n", file, line, msg);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
kernaux_assert_cb = assert_cb;
|
||||||
|
test_main(argc, argv);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ static void my_printf(const char *format, ...)
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
assert(KernAux_Multiboot2_Header_is_valid(
|
assert(KernAux_Multiboot2_Header_is_valid(
|
||||||
(struct KernAux_Multiboot2_Header*)&multiboot2_header_example1
|
(struct KernAux_Multiboot2_Header*)&multiboot2_header_example1
|
||||||
|
@ -28,6 +28,4 @@ int main()
|
||||||
(struct KernAux_Multiboot2_Header*)&multiboot2_header_example1,
|
(struct KernAux_Multiboot2_Header*)&multiboot2_header_example1,
|
||||||
my_printf
|
my_printf
|
||||||
);
|
);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ static void my_printf(const char *format, ...)
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
assert(KernAux_Multiboot2_Header_is_valid(
|
assert(KernAux_Multiboot2_Header_is_valid(
|
||||||
&multiboot2_header_example2.multiboot2_header
|
&multiboot2_header_example2.multiboot2_header
|
||||||
|
@ -28,6 +28,4 @@ int main()
|
||||||
&multiboot2_header_example2.multiboot2_header,
|
&multiboot2_header_example2.multiboot2_header,
|
||||||
my_printf
|
my_printf
|
||||||
);
|
);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ static void my_printf(const char *format, ...)
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
assert(KernAux_Multiboot2_Info_is_valid(
|
assert(KernAux_Multiboot2_Info_is_valid(
|
||||||
(struct KernAux_Multiboot2_Info*)multiboot2_info_example1
|
(struct KernAux_Multiboot2_Info*)multiboot2_info_example1
|
||||||
|
@ -28,6 +28,4 @@ int main()
|
||||||
(struct KernAux_Multiboot2_Info*)multiboot2_info_example1,
|
(struct KernAux_Multiboot2_Info*)multiboot2_info_example1,
|
||||||
my_printf
|
my_printf
|
||||||
);
|
);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ static void my_printf(const char *format, ...)
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
assert(KernAux_Multiboot2_Info_is_valid(
|
assert(KernAux_Multiboot2_Info_is_valid(
|
||||||
&multiboot2_info_example2.multiboot2_info
|
&multiboot2_info_example2.multiboot2_info
|
||||||
|
@ -28,6 +28,4 @@ int main()
|
||||||
&multiboot2_info_example2.multiboot2_info,
|
&multiboot2_info_example2.multiboot2_info,
|
||||||
my_printf
|
my_printf
|
||||||
);
|
);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
{% for case in cases %}
|
{% for case in cases %}
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,4 @@ int main()
|
||||||
assert(spec.base == {{ case.out.base }});
|
assert(spec.base == {{ case.out.base }});
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ static void test(const char *const expected, const char *const format, ...)
|
||||||
assert(strcmp(expected, buffer) == 0);
|
assert(strcmp(expected, buffer) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
#ifdef WITH_IO
|
#ifdef WITH_IO
|
||||||
memset(buffer, '\0', sizeof(buffer));
|
memset(buffer, '\0', sizeof(buffer));
|
||||||
|
@ -81,6 +81,4 @@ int main()
|
||||||
#endif
|
#endif
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#define KERNAUX_PRIVATE_NO
|
#define KERNAUX_PRIVATE_NO
|
||||||
|
|
||||||
#include "helper.h"
|
|
||||||
|
|
||||||
#include <kernaux/alloc.h>
|
#include <kernaux/alloc.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -14,12 +12,10 @@
|
||||||
static void test_default();
|
static void test_default();
|
||||||
static void test_cross_zone_defrag();
|
static void test_cross_zone_defrag();
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
setup_assert_abort();
|
|
||||||
test_default();
|
test_default();
|
||||||
test_cross_zone_defrag();
|
test_cross_zone_defrag();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_default()
|
void test_default()
|
||||||
|
|
|
@ -39,7 +39,7 @@ static const char *const argv_a_X4[] = { "a", "a", "a", "a" };
|
||||||
static const char *const argv_a_X5[] = { "a", "a", "a", "a", "a" };
|
static const char *const argv_a_X5[] = { "a", "a", "a", "a", "a" };
|
||||||
static const char *const argv_a_X6[] = { "a", "a", "a", "a", "a", "a" };
|
static const char *const argv_a_X6[] = { "a", "a", "a", "a", "a", "a" };
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 3, 0, true, "", 3, argv_spaceX3_X3);
|
test("\\ \\ \\ \\ \\ \\ \\ \\ \\ ", 3, 0, true, "", 3, argv_spaceX3_X3);
|
||||||
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 3, 0, true, "", 3, argv_backslashX3_X3);
|
test("\\\\\\\\\\\\ \\\\\\\\\\\\ \\\\\\\\\\\\", 3, 0, true, "", 3, argv_backslashX3_X3);
|
||||||
|
@ -131,8 +131,6 @@ int main()
|
||||||
test(buffer, 256, 4096, false, "buffer overflow", 0, NULL);
|
test(buffer, 256, 4096, false, "buffer overflow", 0, NULL);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test(
|
void test(
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#define BUFFER_SIZE (1024 * 1024)
|
#define BUFFER_SIZE (1024 * 1024)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
void test_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
assert(argc >= 1);
|
assert(argc >= 1);
|
||||||
|
|
||||||
|
@ -25,6 +25,4 @@ int main(int argc, char **argv)
|
||||||
assert(KernAux_ELF_Header_is_valid((struct KernAux_ELF_Header*)buffer));
|
assert(KernAux_ELF_Header_is_valid((struct KernAux_ELF_Header*)buffer));
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
static void create_valid_mbr(struct KernAux_Mbr *mbr);
|
static void create_valid_mbr(struct KernAux_Mbr *mbr);
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
struct KernAux_Mbr mbr;
|
struct KernAux_Mbr mbr;
|
||||||
|
|
||||||
|
@ -31,8 +31,6 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test partition table
|
// TODO: test partition table
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_valid_mbr(struct KernAux_Mbr *const mbr)
|
void create_valid_mbr(struct KernAux_Mbr *const mbr)
|
||||||
|
|
|
@ -48,7 +48,7 @@ static void expect_assert()
|
||||||
#define MEMSET memset(memmap, 0xff, sizeof(memmap))
|
#define MEMSET memset(memmap, 0xff, sizeof(memmap))
|
||||||
#define MEMMAP (*memmap)
|
#define MEMMAP (*memmap)
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
kernaux_assert_cb = assert_cb;
|
kernaux_assert_cb = assert_cb;
|
||||||
|
|
||||||
|
@ -228,6 +228,4 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(assert_count_ctr == assert_count_exp);
|
assert(assert_count_ctr == assert_count_exp);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
info += 8 + (tag) + (data) + (align); \
|
info += 8 + (tag) + (data) + (align); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
assert(sizeof(struct KernAux_Multiboot2_Header) == 16);
|
assert(sizeof(struct KernAux_Multiboot2_Header) == 16);
|
||||||
assert(sizeof(struct KernAux_Multiboot2_Info) == 8);
|
assert(sizeof(struct KernAux_Multiboot2_Info) == 8);
|
||||||
|
@ -161,6 +161,4 @@ int main()
|
||||||
INFO2(efi_64bit_image_handle_ptr, 8, /**/ 0 );
|
INFO2(efi_64bit_image_handle_ptr, 8, /**/ 0 );
|
||||||
INFO2(image_load_base_phys_addr, 4, /**/ 4 );
|
INFO2(image_load_base_phys_addr, 4, /**/ 4 );
|
||||||
INFO0(none /**/ /**/ /**/ );
|
INFO0(none /**/ /**/ /**/ );
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#include "multiboot2_header_example1.h"
|
#include "multiboot2_header_example1.h"
|
||||||
#include "multiboot2_header_example2.h"
|
#include "multiboot2_header_example2.h"
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
// TODO: write this
|
// TODO: write this
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ static const char output2[] =
|
||||||
" flags: 0\n"
|
" flags: 0\n"
|
||||||
" size: 8\n";
|
" size: 8\n";
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
FILE *const fd = popen("./multiboot2_header_print1", "r");
|
FILE *const fd = popen("./multiboot2_header_print1", "r");
|
||||||
|
@ -96,6 +96,4 @@ int main()
|
||||||
const int status = pclose(fd);
|
const int status = pclose(fd);
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
// TODO: write this
|
// TODO: write this
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ static const struct {
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
assert(KernAux_Multiboot2_Info_is_valid(
|
assert(KernAux_Multiboot2_Info_is_valid(
|
||||||
(struct KernAux_Multiboot2_Info*)multiboot2_info_example1
|
(struct KernAux_Multiboot2_Info*)multiboot2_info_example1
|
||||||
|
@ -401,6 +401,4 @@ int main()
|
||||||
&multiboot2_with_two_boot_cmd_lines.multiboot2_info
|
&multiboot2_with_two_boot_cmd_lines.multiboot2_info
|
||||||
) == multiboot2_with_two_boot_cmd_lines.tag_boot_cmd_line1.cmdline
|
) == multiboot2_with_two_boot_cmd_lines.tag_boot_cmd_line1.cmdline
|
||||||
);
|
);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,7 @@ static const char output2[] =
|
||||||
" type: 0 (none)\n"
|
" type: 0 (none)\n"
|
||||||
" size: 8\n";
|
" size: 8\n";
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
FILE *const fd = popen("./multiboot2_info_print1", "r");
|
FILE *const fd = popen("./multiboot2_info_print1", "r");
|
||||||
|
@ -293,6 +293,4 @@ int main()
|
||||||
const int status = pclose(fd);
|
const int status = pclose(fd);
|
||||||
assert(status == 0);
|
assert(status == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -786,7 +786,7 @@ static const struct {
|
||||||
* main *
|
* main *
|
||||||
********/
|
********/
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
// Multiboot2
|
// Multiboot2
|
||||||
|
|
||||||
|
@ -1129,6 +1129,4 @@ int main()
|
||||||
assert(KernAux_Multiboot2_ITag_ELFSymbols_is_valid(
|
assert(KernAux_Multiboot2_ITag_ELFSymbols_is_valid(
|
||||||
&tag_elf_symbols_with_zero_ent_size_valid
|
&tag_elf_symbols_with_zero_ent_size_valid
|
||||||
));
|
));
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,7 @@ static const char *str_end(const char *str)
|
||||||
for (;; ++str) if (*str == '\0') return str;
|
for (;; ++str) if (*str == '\0') return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
char buffer[KERNAUX_UTOA_MIN_BUFFER_SIZE + 3];
|
char buffer[KERNAUX_UTOA_MIN_BUFFER_SIZE + 3];
|
||||||
|
@ -774,6 +774,4 @@ int main()
|
||||||
assert(end2 == str_end(buffer));
|
assert(end2 == str_end(buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ static const char *str_end(const char *str)
|
||||||
for (;; ++str) if (*str == '\0') return str;
|
for (;; ++str) if (*str == '\0') return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
kernaux_assert_cb = assert_cb;
|
kernaux_assert_cb = assert_cb;
|
||||||
|
|
||||||
|
@ -147,6 +147,4 @@ int main()
|
||||||
test_itoa_assert(buffer, 37);
|
test_itoa_assert(buffer, 37);
|
||||||
test_itoa_assert(buffer, -37);
|
test_itoa_assert(buffer, -37);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
struct KernAux_PFA pfa;
|
struct KernAux_PFA pfa;
|
||||||
|
|
||||||
|
@ -83,6 +83,4 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(KernAux_PFA_alloc_pages(&pfa, 1) == 0);
|
assert(KernAux_PFA_alloc_pages(&pfa, 1) == 0);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ static void assert_cb(
|
||||||
longjmp(jmpbuf, 1);
|
longjmp(jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
if (setjmp(jmpbuf) != 0) abort();
|
if (setjmp(jmpbuf) != 0) abort();
|
||||||
|
|
||||||
|
@ -98,6 +98,4 @@ int main()
|
||||||
} else {
|
} else {
|
||||||
assert(count == 10);
|
assert(count == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ static void test_bin(
|
||||||
const char *result
|
const char *result
|
||||||
);
|
);
|
||||||
|
|
||||||
int main()
|
void test_main()
|
||||||
{
|
{
|
||||||
test_raw(0, KERNAUX_UNIT_BIT, "0 bit");
|
test_raw(0, KERNAUX_UNIT_BIT, "0 bit");
|
||||||
test_raw(0, KERNAUX_UNIT_BYTE, "0 Byte");
|
test_raw(0, KERNAUX_UNIT_BYTE, "0 Byte");
|
||||||
|
@ -134,8 +134,6 @@ int main()
|
||||||
test_bin(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "4294967295 GiB");
|
test_bin(UINT32_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "4294967295 GiB");
|
||||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_GIBI, "18446744073709551615 Gibit");
|
test_bin(UINT64_MAX, KERNAUX_UNIT_BIT, KERNAUX_UNITPFX_GIBI, "18446744073709551615 Gibit");
|
||||||
test_bin(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "18446744073709551615 GiB");
|
test_bin(UINT64_MAX, KERNAUX_UNIT_BYTE, KERNAUX_UNITPFX_GIBI, "18446744073709551615 GiB");
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_raw(
|
void test_raw(
|
||||||
|
|
Loading…
Reference in New Issue