• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rewrite unit tests
#31
Quote:I would prefer if the test suite kept running regardless of which tests fail, that's how most unittesting frameworks work. So far I've only noticed that the unfreed pointer counter is not reset between tests, and that was running as non-root. Running as root, the test suite works well (after commenting out the tests that hang or segfault), and nicely reports the only two test failures.
Of course, that would be great for the future, but at this moment, it does not work that way yet. A failing unit test at the moment affects other tests too much.

Quote:Yes, it was run as both root and non-root, but both hang indefinitely.
Let me check if i can test it with your network configuration.

Quote:It's available
Can you debug the I2C code yourself maybe. Add some debug lines to see where it fails?



Can you check my ARP fix? I configured a network device exactly the same as yours and it should work now.
 
Reply
#32
(07-17-2017, 06:22 PM)curlymo Wrote:
Quote:It's available
Can you debug the I2C code yourself maybe. Add some debug lines to see where it fails?
Added a bunch of debug messages, it seems that the call to
Code:
fd = wiringXI2CSetup("/dev/i2c-0", 0x48);
fails. Line 266.

I pushed my stuff to the i2c-debug branch on my clone, the log looks like this:
Code:
martin@linux-s7ea:~/git/pilight/rewrite/build> sudo ./pilight-unittest
registering tests[ test_protocols_i2c_lm75                          ]
starting i2c_lm75 testloading kernel module
found kernel module i2c-stub.ko
init_module
wiringXI2CSetup
and there it segfaults:
Code:
martin@linux-s7ea:~/git/pilight/rewrite/build>  sudo gdb ./pilight-unittest  
GNU gdb (GDB; openSUSE Leap 42.2) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./pilight-unittest...done.
(gdb) run
Starting program: /home/linoM6400/git/pilight/rewrite/build/pilight-unittest
Missing separate debuginfos, use: zypper install glibc-debuginfo-2.22-4.9.1.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
registering tests[ test_protocols_i2c_lm75                          ]
starting i2c_lm75 testloading kernel module
found kernel module i2c-stub.ko
init_module
wiringXI2CSetup

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
Missing separate debuginfos, use: zypper install libdbus-1-3-debuginfo-1.8.22-3.1.x86_64 libnl3-200-debuginfo-3.2.23-4.5.x86_64 libpcap1-debuginfo-1.8.1-7.3.1.x86_64 libunwind-debuginfo-1.1-12.5.x86_64
(gdb) bt full
#0  0x0000000000000000 in ?? ()
No symbol table info available.
#1  0x00007ffff6829ce3 in wiringXI2CSetup () from /usr/lib/libwiringx.so
No symbol table info available.
#2  0x0000000000438d74 in test_protocols_i2c_lm75 (tc=0x7af180) at /home/linoM6400/git/pilight/rewrite/tests/protocols_i2c.c:280
        __FUNCTION__ = "test_protocols_i2c_lm75"
        utsname = {sysname = "Linux", '\000' <repeats 59 times>, nodename = "linux-s7ea.suse", '\000' <repeats 49 times>, release = "4.4.73-18.17-default", '\000' <repeats 44 times>, version = "#1 SMP Fri Jun 23 20:25:06 UTC 2017 (f462a66)", '\000' <repeats 19 times>,
          machine = "x86_64", '\000' <repeats 58 times>, __domainname = "(none)", '\000' <repeats 58 times>}
        path = "/lib/modules/4.4.73-18.17-default", '\000' <repeats 759 times>...
        file = "/lib/modules/4.4.73-18.17-default/kernel/drivers/i2c//i2c-stub.ko", '\000' <repeats 1983 times>
        p = 0x0
        len = 20794
        ret = 0
        add = 0x7ffff5f20678 <main_arena+88> "P\023{"
#3  0x00007ffff73df4c9 in CuTestRun (tc=0x7af180) at /home/linoM6400/git/pilight/rewrite/libs/pilight/core/CuTest.c:143
        buf = {{__jmpbuf = {1, 3698876234951922525, 4230880, 140737488350256, 0, 0, -3698876235555695779, -3698895458928848035}, __mask_was_saved = 0, __saved_mask = {__val = {140737351976608, 0, 140737341045872, 1, 0, 4230880, 140737351976608, 140737488350256,
                140737341420478, 8057216, 8065792, 0, 8065792, 8057216, 3, 140737319667320}}}}
#4  0x00007ffff73dfb55 in CuSuiteRun (testSuite=0x7ab140) at /home/linoM6400/git/pilight/rewrite/libs/pilight/core/CuTest.c:298
        testCase = 0x7af180
        i = 0
#5  0x00000000004090ef in RunAllTests () at /home/linoM6400/git/pilight/rewrite/tests/alltests.c:171
        i = 2
        pth_cur_id = 140737353856832
        r = 0
#6  0x0000000000409206 in main (argc=1, argv=0x7fffffffec38) at /home/linoM6400/git/pilight/rewrite/tests/alltests.c:194
        f = 0x7ab010



The new arp test works good now!
 
Reply
#33
Can you manually compile wiringx with debug symbols enabled to see where wiringXI2CSetup fails?
 
Reply
#34
(07-18-2017, 06:11 AM)curlymo Wrote: Can you manually compile wiringx with debug symbols enabled to see where wiringXI2CSetup fails?
Set CMAKE_BUILD_TYPE to Debug?
 
Reply
#35
Yes, just add this line to the CMakeList:
Code:
set(CMAKE_BUILD_TYPE DEBUG)
 
Reply
#36
New backtrace:

Code:
(gdb) bt full
#0  0x0000000000000000 in ?? ()
No symbol table info available.
#1  0x00007ffff6822045 in wiringXI2CSetup (path=0x4453d3 "/dev/i2c-0", devId=72) at /home/linoM6400/git/wiringx/src/wiringx.c:387
        fd = -1
#2  0x0000000000412e26 in test_protocols_i2c_lm75 (tc=0x7af180) at /home/linoM6400/git/pilight/rewrite/tests/protocols_i2c.c:280
        __FUNCTION__ = "test_protocols_i2c_lm75"
        utsname = {sysname = "Linux", '\000' <repeats 59 times>, nodename = "linux-s7ea.suse", '\000' <repeats 49 times>, release = "4.4.73-18.17-default", '\000' <repeats 44 times>, version = "#1 SMP Fri Jun 23 20:25:06 UTC 2017 (f462a66)", '\000' <repeats 19 times>,
          machine = "x86_64", '\000' <repeats 58 times>, __domainname = "(none)", '\000' <repeats 58 times>}
        path = "/lib/modules/4.4.73-18.17-default", '\000' <repeats 759 times>...
        file = "/lib/modules/4.4.73-18.17-default/kernel/drivers/i2c//i2c-stub.ko", '\000' <repeats 1983 times>
        p = 0x0
        len = 20794
        ret = 0
        add = 0x7ffff5f18678 <main_arena+88> "P\023{"
#3  0x00007ffff73e13f3 in CuTestRun (tc=0x7af180) at /home/linoM6400/git/pilight/rewrite/libs/pilight/core/CuTest.c:143
        buf = {{__jmpbuf = {1, -4627543101834344436, 4230880, 140737488350256, 0, 0, 4627543101097560076, 4627523853004490764}, __mask_was_saved = 0, __saved_mask = {__val = {140737351976608, 0, 140737341045872, 1, 0, 4230880, 140737351976608, 140737488350256,
                140737341428456, 8057216, 8065792, 0, 8065792, 8057216, 3, 140737319634552}}}}
#4  0x00007ffff73e1a7f in CuSuiteRun (testSuite=0x7ab140) at /home/linoM6400/git/pilight/rewrite/libs/pilight/core/CuTest.c:298
        testCase = 0x7af180
        i = 0
#5  0x00000000004090ef in RunAllTests () at /home/linoM6400/git/pilight/rewrite/tests/alltests.c:171
        i = 2
        pth_cur_id = 140737353856832
        r = 0
#6  0x0000000000409206 in main (argc=1, argv=0x7fffffffec38) at /home/linoM6400/git/pilight/rewrite/tests/alltests.c:194
        f = 0x7ab010
Seems the call to open /dev/i2c-0 fails and returns -1. Line 387: and surrounding code:

Code:
    if((fd = open(path, O_RDWR)) < 0) {
        wiringXLog(LOG_ERR, "wiringX failed to open %s for reading and writing", path);    // line 387
        return -1;
    }

wiringXLog seems to segfault, commenting it out stops the segfaults. However, the unittest still fails.



unittest fail logs:

Code:
martin@linux-s7ea:~/git/pilight/rewrite/build> sudo ./pilight-unittest
[ test_protocols_i2c_lm75                          ]
[ test_protocols_i2c_lm76                          ]
[ test_protocols_i2c_bmp180                        ]
FFF

There were 3 failures:
1) test_protocols_i2c_lm75: /home/linoM6400/git/pilight/rewrite/tests/protocols_i2c.c:283: assert failed
2) test_protocols_i2c_lm76: /home/linoM6400/git/pilight/rewrite/tests/protocols_i2c.c:378: assert failed
3) test_protocols_i2c_bmp180: /home/linoM6400/git/pilight/rewrite/tests/protocols_i2c.c:458: assert failed

!!!FAILURES!!!
Runs: 3 Passes: 0 Fails: 3

They all fail at the same CuAssert, right after the wiringXI2CSetup
 
Reply
#37
Fixed. Can you check why i2c-stub does not load /dev/i2c-0? The fix does require the latest wiringX (available on the apt repo).
 
Reply
#38
(07-18-2017, 09:32 PM)curlymo Wrote: Can you check why i2c-stub does not load /dev/i2c-0?
Not sure how, but /dev/i2c-0 doesn't exist in the first place.

(07-18-2017, 09:32 PM)curlymo Wrote: The fix does require the latest wiringX (available on the apt repo).
Yeah, just updated my clone and recompiled. No more segfaults, just test failures now Smile
 
Reply
#39
The whole point of i2c-stub is that it loads a dummy i2c device to be used for unit-testing. So, i'm wondering why that in general fails on your system.

Can you manually load i2c-stub and check what dmesg says?
 
Reply
#40
I had to load the i2c-dev module with dmesg too, then /dev/i2c-0 showed up. Now the tests fail at wiringXI2CWriteReg16 calls such as
Code:
CuAssertIntEquals(tc, 0, wiringXI2CWriteReg16(fd, 0x00, 0xA017));
instead, which return -1 when they should return 0.
dmesg reports a timeout waiting for interrupt and a transaction timeout when these tests are run, probably related?

Code:
-- i801_smbus 0000:00:1f.3: Timeout waiting for interrupt!
i801_smbus 0000:00:1f.3: Transaction timeout

Any ideas how to track this one down further?
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)