Zhibin Li's GSoC status report - #1 of #13

Zhibin Li 08826794brmt at gmail.com
Fri May 25 08:34:33 UTC 2018


Hi, all

Sorry again for the missing status reports. Since it's a bit late, I would
like not to bother sending two emails (#0 adn #1) and just summarize what I
did and what I'm going to do next in this email.

Work outline:

1. It took me quite a while to understand how the entire test suite works
on
comparing and measuring coverage. Since coverage is one of the important
point of the project, now I want to share what I've learned at first.
Strace's coverage report is based on gcov and made graphical and visible
by lcov.

$ ./configure --enable-code-coverage && make check-code-coverage

And one thing that I didn't know before is that how gcov measures "branch".
According to the theory about branch testing, "branches" come from decision
points, that is, literally true or false. For example, an
"if (condition) { ... }" has two branches because the "if" is a decision
point and "switch ... case ..." is similar.
So when I saw the code below:

if (entering(tcp) || syserror(tcp) || tcp->u_rval == 0)
        return 0;

I simply thougt there were just two branches which need to be covered. But
the lcov web page shows there are 6 branches and it seemes like something
related to condition coverage, at least not theoretical branch coverage.
And I'm curious about how these "branches" are mearsured because they are
more like "conditions" instead of "branches". Besides, from branch 0 to 5,
which condition should I refer to? I did some research on it and found a
testing method called MC/DC (Modified condition/decision coverage), which
is a combination of condition and decision in a way. For making better
coverage, this makes sense.
Take the simpler code below as example:

if (i == 1 || j != 0 || k == 2)
        return 0;

When seeing from the gcov's side, the code looks like this:

if (i != 1) { //branch 0
        if (j == 0) {    //branch 2
                if (k != 2) {   //branch 4
                        //next statement
                } else {        //branch 5
                        return 0;
                }
        } else {        //branch 3
                return 0;
        }
} else {        //branch1
        return 0;
}

I'm not so sure whether I'm understanding this right. Any comments and
suggestions are welcome :).

2. About how to run the test suite. Actually it's easy to run the tests
manually by executing:

$ make check

Basically it runs tests in tests/, tests-m32/, tests-mx32/ directories. But
I've been using fedora, which is a Red Hat based distribution and found that
tests in tests-mx32 never run. According to strace's man page, mx32-mpers
is
"non-native 32-on-64-bit binaries", x32 ABI, in other words. I found this
website[0] but it's a little bit out-of-date. With Dmitry and eSyr's help I
noticed that's because fedora doesn't provide x32 ABI support officially so
I installed an ubuntu on my laptop and it turned out Debian based distros
have x32 ABI support enabled by default. Other websites I found are [1] and
[2].

3. I write part of test [3] for fcntl syscall to make its coverage reach
100%
based on what I've learned about coverage so I know which part of tests are
missing. But it's more like a draft because it's not concise at all. I'd
appreciate any reviewing and comments on the code. I'm now taking
membarrier
test and [4] as reference according to eSyr's suggestion.

TODO:
I've skimed through the man page of fcntl, bpf and have an overview now so
the next step is to send patches or make the code I've already wrriten
qualified to be merged.
Of course there still a lot of syscall and their options/flags I don't know
well enough. I'm planning to investigate syscalls related to socket and
quota and improve the test coverage for them.
I don't know much about glibc and when it comes to portability and
compatibility (e.g. #ifdef something ... #include <something.h> ...
#endif),
I got stuck so I have to learn it by referring more examples. If anyone
knows a
better way to learn it, please tell me. Thanks!

[0]https://sites.google.com/site/x32abi/
[1]https://wiki.debian.org/X32Port
[2]https://sourceware.org/glibc/wiki/x32
[3]https://github.com/haoyouab/strace/commits/master
[4]
https://github.com/esyr-rh/strace/commit/23450af02dbdb9477ffedf44ff026ed59d2d2c73


Zhibin Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180525/b8188306/attachment.html>


More information about the Strace-devel mailing list