aboutsummaryrefslogtreecommitdiff
path: root/test/config.c
blob: 978e0036f92db114276e9d06c3f3e987d54e51af (plain)
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

#include "kpl_test.h"

KPL_TEST(show_help) {
    kpl_config config;
    const int32_t argc = 2;
    const char *argv[] = { "./kpl",  "--help", "not_used" };
    kpl_config_init(&config);
    int32_t code = kpl_config_parse_args(&config, argc, argv);
    KPL_ASSERT(code == KPL_EXIT_CODE_HELP, "Invalid help exit code");
}

KPL_TEST(change_module_extension) {
    kpl_config config;
    const int32_t argc = 3;
    const char *argv[] = { "./kpl", "--module-extension=.l", "./file.l" };
    kpl_config_init(&config);
    int32_t code = kpl_config_parse_args(&config, argc, argv);
    KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
    KPL_ASSERT(strcmp(config.module_extension, ".l") == 0, "Invalid new module extension");
}

KPL_TEST(io_queue_pow2) {
    kpl_config config;
    const int32_t argc = 3;
    const char *argv[] = { "./kpl", "--io-queue-pow2=14", "./file.kpl" };
    kpl_config_init(&config);
    int32_t code = kpl_config_parse_args(&config, argc, argv);
    KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
    KPL_ASSERT(config.io.queue_pow2 == 14, "Invalid io queue power of two");
}

KPL_TEST(thread_count) {
    kpl_config config;
    const int32_t argc = 3;
    const char *argv[] = { "./kpl", "--thread-count=1", "./file.kpl" };
    kpl_config_init(&config);
    int32_t code = kpl_config_parse_args(&config, argc, argv);
    KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
    KPL_ASSERT(config.thread.count == 1, "Invalid thread count");
}

KPL_TEST(memory_pool_pow2) {
    kpl_config config;
    const int32_t argc = 3;
    const char *argv[] = { "./kpl", "--memory-pool-pow2=6,7", "./file.kpl" };
    kpl_config_init(&config);
    int32_t code = kpl_config_parse_args(&config, argc, argv);
    KPL_ASSERT(code == KPL_EXIT_CODE_SUCCESS, "Invalid exit code");
    KPL_ASSERT(config.thread.ring_pool_entries_pow2[6] == 7, "Invalid entries pow2");
}