mtd: unittests: Stop testing stat() calls
PATCH 1/1 mtd: unittests: Stop testing stat() calls
Sometimes __xstat is called instead that makes tests fragile.
--- tests/unittests/Makemodule.am | 2 +- tests/unittests/libmtd_test.c | 2 -- tests/unittests/libubi_test.c | 1 - tests/unittests/test_lib.h | 12 ------------ 4 files changed, 1 insertion(+), 16 deletions(-)
tests/unittests/Makemodule.am +1 -1
@@ -1,6 +1,6 @@ ubilib_test_SOURCES = tests/unittests/libubi_test.c lib/libubi.c ubilib_test_LDADD = $(CMOCKA_LIBS) -ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=stat -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek +ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek ubilib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I include -DSYSFS_ROOT='"tests/unittests/sysfs_mock"' mtdlib_test_SOURCES = tests/unittests/libmtd_test.c lib/libmtd.c lib/libmtd_legacy.c
tests/unittests/libmtd_test.c +0 -2
@@ -53,7 +53,6 @@ static void test_mtd_dev_present(void **state) {int ret;libmtd_t lib =mock_libmtd_open (); -expect_stat (SYSFS_ROOT "/class/mtd/mtd0" ,0 ); ret =mtd_dev_present (lib,0 );assert_int_equal (ret,1 );libmtd_close (lib);
@@ -423,7 +422,6 @@ static void test_mtd_get_dev_info1(void **state)struct mtd_dev_info info;int dev_num =0 ;memset (&info,0 ,sizeof (info)); -expect_stat (SYSFS_ROOT "/class/mtd/mtd0" ,0 );expect_open (SYSFS_ROOT "/class/mtd/mtd0/dev" ,O_RDONLY ,0 );expect_read_real (50 ,0 );expect_read (1 ,0 );
tests/unittests/libubi_test.c +0 -1
@@ -98,7 +98,6 @@ static libubi_t mock_libubi_open()static void test_ubi_dev_present (void **state) {libubi_t lib =mock_libubi_open (); -expect_stat (SYSFS_ROOT "/class/ubi/ubi0" ,0 );int r =ubi_dev_present (lib,0 );assert_int_equal (r,1 );
tests/unittests/test_lib.h +0 -12
@@ -58,13 +58,6 @@ int __wrap_ioctl(int fd, int req, ...)return retval; } -int __wrap_stat (const char *path,struct stat *buf) -{ -check_expected (path); -assert_non_null (buf); -return mock_type (int); -} -int __wrap_read (int fd,char *buf,size_t len) {assert_true (fd >0 );
@@ -121,11 +114,6 @@ off_t __wrap_lseek(int fd, off_t seek, int whence)will_return (__wrap_ioctl,0 );\ }while (0 ); -#define expect_stat (X ,Y ) do { \ - expect_string(__wrap_stat, path, X);\ - will_return(__wrap_stat, Y);\ - } while(0); -#define expect_write (X ,Y ,Z ) do { \ will_return(__wrap_write, X);\ will_return(__wrap_write, Y);\
Signature · 1 line
2.14.1
David Oberhollenzer
AppliedApplied to mtd-utils.git
tests/unittests/Makemodule.am line 4
Quoted 10 lines · Balint Reczey
tests/unittests/Makemodule.am +1
-1@@ -1,6 +1,6 @@ ubilib_test_SOURCES = tests/unittests/libubi_test.c lib/libubi.c ubilib_test_LDADD = $(CMOCKA_LIBS) -ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=stat -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek +ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek ubilib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I include -DSYSFS_ROOT='"tests/unittests/sysfs_mock"'
I took the liberty of duplicating this change for libmtd_test defined below in the same file, otherwise it wouldn't link due to a lack of the function your patch removes.
Thanks,
David