Compare commits
No commits in common. "25b0e92ed095a8b175e3e8f92ae591c7d1e8c2ae" and "235df4a64825bfd30e4928273ab6ceaba47b467a" have entirely different histories.
25b0e92ed0
...
235df4a648
52
.gitignore
vendored
52
.gitignore
vendored
@ -1,52 +0,0 @@
|
|||||||
# Prerequisites
|
|
||||||
*.d
|
|
||||||
|
|
||||||
# Object files
|
|
||||||
*.o
|
|
||||||
*.ko
|
|
||||||
*.obj
|
|
||||||
*.elf
|
|
||||||
|
|
||||||
# Linker output
|
|
||||||
*.ilk
|
|
||||||
*.map
|
|
||||||
*.exp
|
|
||||||
|
|
||||||
# Precompiled Headers
|
|
||||||
*.gch
|
|
||||||
*.pch
|
|
||||||
|
|
||||||
# Libraries
|
|
||||||
*.lib
|
|
||||||
*.a
|
|
||||||
*.la
|
|
||||||
*.lo
|
|
||||||
|
|
||||||
# Shared objects (inc. Windows DLLs)
|
|
||||||
*.dll
|
|
||||||
*.so
|
|
||||||
*.so.*
|
|
||||||
*.dylib
|
|
||||||
|
|
||||||
# Executables
|
|
||||||
*.exe
|
|
||||||
*.out
|
|
||||||
*.app
|
|
||||||
*.i*86
|
|
||||||
*.x86_64
|
|
||||||
*.hex
|
|
||||||
|
|
||||||
# Debug files
|
|
||||||
*.dSYM/
|
|
||||||
*.su
|
|
||||||
*.idb
|
|
||||||
*.pdb
|
|
||||||
|
|
||||||
# Kernel Module Compile Results
|
|
||||||
*.mod*
|
|
||||||
*.cmd
|
|
||||||
.tmp_versions/
|
|
||||||
modules.order
|
|
||||||
Module.symvers
|
|
||||||
Mkfile.old
|
|
||||||
dkms.conf
|
|
68
test.h
68
test.h
@ -1,68 +0,0 @@
|
|||||||
// include this file in all the test files
|
|
||||||
|
|
||||||
#ifndef _TEST_MDB_H
|
|
||||||
#define _TEST_MDB_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define VERSION "0.0.1" // this is not really used anywhere
|
|
||||||
|
|
||||||
#define COLOR_RED "\x1b[31;1m"
|
|
||||||
#define COLOR_RED_REGULAR "\x1b[31m"
|
|
||||||
#define COLOR_GREEN "\x1b[32;1m"
|
|
||||||
#define COLOR_YELLOW "\x1b[33;1m"
|
|
||||||
#define COLOR_RESET "\x1b[0m"
|
|
||||||
|
|
||||||
#define MAX_TEST_FUNCS 256
|
|
||||||
|
|
||||||
typedef int (*test_func_t)();
|
|
||||||
|
|
||||||
int total = 0;
|
|
||||||
int success = 0;
|
|
||||||
static test_func_t test_functions[MAX_TEST_FUNCS];
|
|
||||||
|
|
||||||
#define TEST_INIT(...) \
|
|
||||||
int main(void) { \
|
|
||||||
printf("=========================================================================\n"); \
|
|
||||||
printf("TEST %s\n", __FILE__); \
|
|
||||||
__VA_ARGS__ \
|
|
||||||
for (int i = 0; i < total; i++) { \
|
|
||||||
if (test_functions[i]()) success++; \
|
|
||||||
} \
|
|
||||||
int failed = total - success; \
|
|
||||||
printf("\n%s - (%d/%d) passed (%d) failed\n" COLOR_RESET, (failed == 0) ? COLOR_GREEN "PASSED" : COLOR_RED "FAILED", success, total, failed); \
|
|
||||||
printf("=========================================================================\n"); \
|
|
||||||
return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TEST(NAME, BLOCK) \
|
|
||||||
static int test_##NAME(); \
|
|
||||||
__attribute__((constructor)) static void register_test_##NAME() { \
|
|
||||||
if (total < MAX_TEST_FUNCS) { \
|
|
||||||
test_functions[total++] = test_##NAME; \
|
|
||||||
} else { \
|
|
||||||
fprintf(stderr, "Max amount of test functions reached\n"); \
|
|
||||||
exit(EXIT_FAILURE); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
static int test_##NAME() { \
|
|
||||||
printf("\ntest_" #NAME "\n"); \
|
|
||||||
int total_assert = 0; \
|
|
||||||
int total_success = 0; \
|
|
||||||
BLOCK \
|
|
||||||
printf("\t(%d/%d) passed (%d) failed\n", total_success, total_assert, total_assert - total_success); \
|
|
||||||
return (total_assert == total_success); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ASSERT(COND, MSG) \
|
|
||||||
do { \
|
|
||||||
total_assert++; \
|
|
||||||
if ((COND)) { \
|
|
||||||
total_success++; \
|
|
||||||
} else { \
|
|
||||||
printf("\t" COLOR_RED_REGULAR "assertion failed (l.no - %d) [" #COND "] " COLOR_YELLOW " - %s\n" COLOR_RESET, __LINE__, MSG); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user