novaprova单元测试框架:未检测到任何测试

时间:2018-05-04 12:49:12

标签: c unit-testing

我创建了一个简单的测试,当我用novaprova编译它时,它没有发现测试。

novaprova 实际上是从我的平台构建的,这是一个 x86 Linux 自定义平台。

有没有人见过类似的问题?

以下是我所拥有的 novaprova 测试的启用调试的输出。

./testrunner
np: creating testmanager_t instance
np: NovaProva Copyright (c) Gregory Banks
np: Built for O/S linux architecture x86
np: adding classifier /^test_([a-z0-9].*)/ -> test
...
...
np: adding classifier /^__np_parameter_(.*)/ -> param
np: creating np::spiegel::dwarf::state_t instance
np: state_t::add_self: platform linkobj (null)
np: state_t::add_self: platform linkobj /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/libstdc++.so.6
np: state_t::add_self: platform linkobj /usr/i486-pc-linux-gnu/lib/libbfd-2.18.so
np: state_t::add_self: have spiegel linkobj
np: state_t::add_self: platform linkobj /lib/libdl.so.2
np: state_t::add_self: platform linkobj /lib/librt.so.1
np: state_t::add_self: platform linkobj /usr/lib/libxml2.so.2
np: state_t::add_self: platform linkobj /usr/lib/libglib-2.0.so.0
np: state_t::add_self: platform linkobj /lib/libpthread.so.0
np: state_t::add_self: platform linkobj /lib/libz.so.1
np: state_t::add_self: platform linkobj /usr/lib/libcrypto.so.0.9.8
np: state_t::add_self: platform linkobj /usr/lib/libcurl.so.4
np: state_t::add_self: platform linkobj /lib/libm.so.6
np: state_t::add_self: platform linkobj /usr/lib/gcc/i486-pc-linux-gnu/4.1.2/libgcc_s.so.1
np: state_t::add_self: platform linkobj /lib/libc.so.6
np: state_t::add_self: platform linkobj /lib/ld-linux.so.2
np: state_t::add_self: platform linkobj /usr/lib/libssl.so.0.9.8
np: opening bfd /usr/i486-pc-linux-gnu/lib/libbfd-2.18.so
np: sections:
np: section name .hash size 1ce0 filepos 114 index -1
np: section name .gnu.hash size 1ca0 filepos 1df4 index -1
np: section name .dynsym size 33d0 filepos 3a94 index -1
np: section name .dynstr size 4823 filepos 6e64 index -1
np: section name .gnu.version size 67a filepos b688 index -1
np: section name .gnu.version_r size 50 filepos bd04 index -1
np: section name .rel.dyn size 8010 filepos bd54 index -1
np: section name .rel.plt size d60 filepos 13d64 index -1
np: section name .init size 17 filepos 14ac4 index -1
np: section name .plt size 1ad0 filepos 14adc index 9
np: found system mapping for section .plt
np: section name .text size 89474 filepos 165b0 index -1
np: section name .fini size 1c filepos 9fa24 index -1
np: section name .rodata size 10c7b filepos 9fa40 index -1
np: section name .eh_frame_hdr size 1c filepos b06bc index -1
np: section name .eh_frame size 5c filepos b06d8 index -1
np: section name .ctors size 8 filepos b0fa8 index -1
np: section name .dtors size 8 filepos b0fb0 index -1
np: section name .jcr size 4 filepos b0fb8 index -1
np: section name .data.rel.ro size 6e60 filepos b0fc0 index -1
np: section name .dynamic size d0 filepos b7e20 index -1
np: section name .got size f0 filepos b7ef0 index -1
np: section name .got.plt size 6bc filepos b7ff4 index -1
np: section name .data size fc0 filepos b86c0 index -1
np: section name .bss size 41f0 filepos b9680 index -1
np: debug sections map:
np: index 0 name .debug_aranges map 0x0 size 0x0
np: index 1 name .debug_pubnames map 0x0 size 0x0
np: index 2 name .debug_info map 0x0 size 0x0
np: index 3 name .debug_abbrev map 0x0 size 0x0
np: index 4 name .debug_line map 0x0 size 0x0
np: index 5 name .debug_frame map 0x0 size 0x0
np: index 6 name .debug_str map 0x0 size 0x0
np: index 7 name .debug_loc map 0x0 size 0x0
np: index 8 name .debug_ranges map 0x0 size 0x0
np: index 9 name .plt map 0x55678adc size 0x1ad0
np: reading compile units for linkobj /usr/i486-pc-linux-gnu/lib/libbfd-2.18.so
np: DWARF compile unit header at section offset 0x0
np: scanning for test functions
np: WARNING: no tests discovered
np: running
np: 0 run 0 failed

1 个答案:

答案 0 :(得分:1)

查看novaprova框架和您的问题,我已经找到了以下文档:Writing Test Functions

引用“测试树”部分:

  

测试树

     

大多数其他测试框架提供了一个简单的2级机制来组织测试;测试分为套件。

     

相比之下,NovaProva将测试组织到测试节点树中。所有   测试可执行文件中内置的测试是在运行时收集的   安装在树上,有一个共同的根。然后修剪根部   直到测试名称尽可能短。每个测试功能都是一个   此树中的叶节点(通常)。

     

此树中的测试位置源自   test function,包含测试源文件的basename   测试函数,以及包含的文件系统目录的层次结构   那个源文件。这些形成了一种自然的分类方案   已经通过选择文件名和函数的名称来控制。   这些名称按照从最少到最具体的顺序粘在一起,   用ASCII'。'字符分隔,一般看起来像这样。

dir.subdir.more.subdirs.filename.function 

这是一个示例,显示测试节点名称如何自然地落在测试代码组织之外。

% cat tests/startrek/tng/federation/enterprise.c 
static void test_torpedoes(void) {
    fprintf(stderr, "Testing photon torpedoes\n"); }

% cat tests/startrek/tng/klingons/neghvar.c 
static void test_disruptors(void) {
    fprintf(stderr, "Testing disruptors\n"); }

% cat tests/starwars/episode4/rebels/xwing.c 
static void test_lasers(void) {
    fprintf(stderr, "Testing laser cannon\n"); }

% ./testrunner --list 
tests.startrek.tng.federation.enterprise.torpedoes
tests.startrek.tng.klingons.neghvar.disruptors
tests.starwars.episode4.rebels.xwing.lasers

请注意,对于每个通过provanove认可的测试,使用以下函数签名:

static void test_[your tested function name](void) {

根据您的问题 - 这似乎是造成您问题的罪魁祸首。

相关问题