Skip to content

Commit

Permalink
tests: Relax stat nlink checks
Browse files Browse the repository at this point in the history
They don't really have an obvious "correct" value, and sometimes fail on
ARM machines.
  • Loading branch information
martinpitt committed Jan 18, 2022
1 parent 7debc24 commit 48fabfd
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions tests/test-umockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,50 +1127,45 @@ t_testbed_libc(UMockdevTestbedFixture * fixture, UNUSED_DATA)

/* stat */
g_assert_cmpint(stat ("/sys/bus/pci/devices", &st), ==, 0);
g_assert_cmpint(st.st_nlink, ==, 2);
g_assert_cmpint(st.st_nlink, >=, 1);
g_assert_cmpint(st.st_nlink, <=, 2);
g_assert_cmpuint(st.st_uid, ==, uid);
g_assert(S_ISDIR(st.st_mode));

g_assert_cmpint(lstat ("/sys/bus/pci/devices/dev1", &st), ==, 0);
g_assert_cmpint(st.st_nlink, ==, 1);
g_assert_cmpuint(st.st_uid, ==, uid);
g_assert(S_ISLNK(st.st_mode));

g_assert_cmpint(stat ("/sys/bus/pci/devices/dev1", &st), ==, 0);
g_assert_cmpint(st.st_nlink, ==, 2);
g_assert_cmpuint(st.st_uid, ==, uid);
g_assert(S_ISDIR(st.st_mode));

g_assert_cmpint(fstatat (AT_FDCWD, "/sys/bus/pci/devices", &st, 0), ==, 0);
g_assert_cmpint(st.st_nlink, ==, 2);
g_assert_cmpuint(st.st_uid, ==, uid);
g_assert(S_ISDIR(st.st_mode));

g_assert_cmpint(fstatat (AT_FDCWD, "/sys/bus/pci/devices/dev1", &st, AT_SYMLINK_NOFOLLOW), ==, 0);
g_assert_cmpint(st.st_nlink, ==, 1);
g_assert_cmpuint(st.st_uid, ==, uid);
g_assert(S_ISLNK(st.st_mode));

g_assert_cmpint(fstatat (AT_FDCWD, "/sys/bus/pci/devices/dev1", &st, 0), ==, 0);
g_assert_cmpint(st.st_nlink, ==, 2);
g_assert_cmpuint(st.st_uid, ==, uid);
g_assert(S_ISDIR(st.st_mode));

#ifdef __GLIBC__
/* statx */
struct statx stx;
g_assert_cmpint(statx (AT_FDCWD, "/sys/bus/pci/devices", 0, STATX_TYPE|STATX_NLINK|STATX_UID, &stx), ==, 0);
g_assert_cmpint(stx.stx_nlink, ==, 2);
g_assert_cmpint(stx.stx_nlink, >=, 1);
g_assert_cmpint(stx.stx_nlink, <=, 2);
g_assert_cmpuint(stx.stx_uid, ==, uid);
g_assert(S_ISDIR(stx.stx_mode));

g_assert_cmpint(statx (AT_FDCWD, "/sys/bus/pci/devices/dev1", AT_SYMLINK_NOFOLLOW, STATX_TYPE|STATX_NLINK|STATX_UID, &stx), ==, 0);
g_assert_cmpint(stx.stx_nlink, ==, 1);
g_assert_cmpuint(stx.stx_uid, ==, uid);
g_assert(S_ISLNK(stx.stx_mode));

g_assert_cmpint(statx (AT_FDCWD, "/sys/bus/pci/devices/dev1", 0, STATX_TYPE|STATX_NLINK|STATX_UID, &stx), ==, 0);
g_assert_cmpint(stx.stx_nlink, ==, 2);
g_assert_cmpuint(stx.stx_uid, ==, uid);
g_assert(S_ISDIR(stx.stx_mode));
#endif
Expand Down

0 comments on commit 48fabfd

Please sign in to comment.