summaryrefslogtreecommitdiff
path: root/unittests
AgeCommit message (Collapse)Author
2020-07-02num2str(): Add the E (exa) prefixBart Van Assche
This change guarantees that all 64-bit integers that should be assigned a multiplier are assigned a multiplier. Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-07-02Add a num2str() unit testBart Van Assche
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-01-06lib/memalign: remove smalloc()/sfree() dependencyTomohiro Kusumi
fio_memalign()/fio_memfree() implementation shouldn't depend on smalloc()/sfree() which has dependency on fio code itself. e.g. This forces unittest code to prepare stab functions for smalloc()/sfree(). This smalloc()/sfree() dependency was added by 3114b675fd ("fio: enable cross-thread overlap checking with processes"). Rename fio_memalign()/fio_memfree() to __fio_memalign()/__fio_memfree() and take a function pointer instead of a boolean flag. Add fio_memalign()/fio_memfree() as an inlined wrapper for __fio_memalign()/__fio_memfree() without API change. The only real change here is lib/memalign functions got renamed. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
2019-12-22unittests: add unittest suite for oslib/strsep.cTomohiro Kusumi
See b8b0e1eea7780a02ff67f0caeba446cc403f1b37 ("unittests: add CUnit based unittest framework") for usage. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
2019-12-22unittests: add unittest suite for oslib/strcasestr.cTomohiro Kusumi
See b8b0e1eea7780a02ff67f0caeba446cc403f1b37 ("unittests: add CUnit based unittest framework") for usage. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
2018-10-26unittests: add unittest suite for oslib/strndup.cTomohiro Kusumi
Add test cases for oslib/strndup.c as an example of unittest. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-10-26unittests: add unittest suite for oslib/strlcat.cTomohiro Kusumi
Add test cases for oslib/strlcat.c as an example of unittest. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-10-26unittests: add unittest suite for lib/strntol.cTomohiro Kusumi
Add test cases for lib/strntol.c as an example of unittest. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-10-26unittests: add unittest suite for lib/memalign.cTomohiro Kusumi
Add test cases for lib/memalign.c as an example of unittest. A workaround code to emulate smalloc()/sfree() was needed since 3114b675fd("fio: enable cross-thread overlap checking with processes") introduced dependency on smalloc()/sfree() which has dependency on fio code. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-10-26unittests: add CUnit based unittest frameworkTomohiro Kusumi
CUnit is C version of *unit framework to help write test cases. https://sourceforge.net/projects/cunit/ unittests/* are compiled only if CUnit exists, and detected on build time in ./configure like any other build time detection, by running a simple CUnit initialization code. Some OS/distros have binary package for CUnit. In case of Fedora and FreeBSD, they both install shared library (libcunit.so) and CUnit headers required to compile fio's unittests. Fedora: # dnf install CUnit FreeBSD: # pkg install cunit To build and install CUnit from upstream source, do below. # ./bootstrap && make && make install Note that make install seems to install binaries and headers under ~/CUnitHome/ by default. After applying actual test cases in the next few commits, running ./unittests/unittest will print results to stdout. These are examples of test cases, and one can add more tests. -- Example of unittest results # ./unittests/unittest CUnit - A unit testing framework for C - Version 2.1-3 http://cunit.sourceforge.net/ Suite: lib/memalign.c Test: memalign/1 ...passed Suite: lib/strntol.c Test: strntol/1 ...passed Test: strntol/2 ...FAILED 1. unittests/lib/strntol.c:24 - CU_ASSERT_EQUAL(*endp,'\0') Test: strntol/3 ...passed Suite: oslib/strlcat.c Test: strlcat/1 ...passed Test: strlcat/2 ...FAILED 1. unittests/oslib/strlcat.c:28 - CU_ASSERT_EQUAL(strcmp(dst, ""),0) Suite: oslib/strndup.c Test: strndup/1 ...passed Test: strndup/2 ...passed Test: strndup/3 ...passed Run Summary: Type Total Ran Passed Failed Inactive suites 4 4 n/a 0 0 tests 9 9 7 2 0 asserts 18 18 16 2 n/a Elapsed time = 0.000 seconds Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>