From 9c6173559f95e939e66efb2ec3193d6f3618cf69 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Tue, 6 Feb 2018 05:31:32 +0700 Subject: mtd: unittests: Stop testing stat() calls Sometimes __xstat is called instead that makes tests fragile. Signed-off-by: David Oberhollenzer --- tests/unittests/Makemodule.am | 4 ++-- tests/unittests/libmtd_test.c | 2 -- tests/unittests/libubi_test.c | 1 - tests/unittests/test_lib.h | 12 ------------ 4 files changed, 2 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/unittests/Makemodule.am b/tests/unittests/Makemodule.am index 0ecdaa9..e2fa989 100644 --- a/tests/unittests/Makemodule.am +++ b/tests/unittests/Makemodule.am @@ -1,11 +1,11 @@ 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 mtdlib_test_LDADD = $(CMOCKA_LIBS) -mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=stat -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=write +mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=write mtdlib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I lib/ -I include -DSYSFS_ROOT='"tests/unittests/sysfs_mock"' TEST_BINS = \ diff --git a/tests/unittests/libmtd_test.c b/tests/unittests/libmtd_test.c index f36fb56..db1564a 100644 --- a/tests/unittests/libmtd_test.c +++ b/tests/unittests/libmtd_test.c @@ -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); diff --git a/tests/unittests/libubi_test.c b/tests/unittests/libubi_test.c index 8deae91..35eb28f 100644 --- a/tests/unittests/libubi_test.c +++ b/tests/unittests/libubi_test.c @@ -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); diff --git a/tests/unittests/test_lib.h b/tests/unittests/test_lib.h index 806a4bc..7a6a003 100644 --- a/tests/unittests/test_lib.h +++ b/tests/unittests/test_lib.h @@ -57,13 +57,6 @@ int __wrap_ioctl(int fd, unsigned long 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); @@ -118,11 +111,6 @@ off_t __wrap_lseek(int fd, off_t seek, int whence) will_return(__wrap_ioctl, NULL);\ } 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);\ -- cgit v1.2.3