diff options
author | Roland Levillain <rpl@google.com> | 2024-03-25 18:50:20 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-03-25 18:50:20 +0000 |
commit | 0cf14353017f64686665f4585739d1d6407b36f9 (patch) | |
tree | 4e7868633c53911d112c9bb8414a2f7909c82371 | |
parent | b4a31f8580dcfc05395e242abda6b235a06ba896 (diff) | |
parent | 6bf67dc51bfac1408688e2ac33948f1642151d1e (diff) | |
download | libcore-0cf14353017f64686665f4585739d1d6407b36f9.tar.gz |
Merge "Add test for `android.system.StructStat.StructStat`." into android12-tests-devandroid12-tests-dev
-rw-r--r-- | luni/src/test/java/libcore/android/system/OsTest.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/android/system/OsTest.java b/luni/src/test/java/libcore/android/system/OsTest.java index 649baa4ffc3..77b80c1251e 100644 --- a/luni/src/test/java/libcore/android/system/OsTest.java +++ b/luni/src/test/java/libcore/android/system/OsTest.java @@ -26,6 +26,7 @@ import android.system.StructCmsghdr; import android.system.StructMsghdr; import android.system.StructRlimit; import android.system.StructStat; +import android.system.StructTimespec; import android.system.StructTimeval; import android.system.StructUcred; import android.system.UnixSocketAddress; @@ -1736,6 +1737,19 @@ public class OsTest { } @Test + public void test_build_sruct_stat() { + StructStat structStat1 = new StructStat(/*st_dev*/ 0L, /*st_ino*/ 0L, /*st_mode*/ 0, + /*st_nlink*/ 1L, /*st_uid*/ 1000, /*st_gid*/ 1000, /*st_rdev*/ 0L, /*st_size*/ 0L, + /*st_atime*/ 0L, /*st_mtime*/ 0L, /*st_ctime*/ 0L, /*st_blksize*/ 4096L, + /*st_blocks*/ 1L); + StructStat structStat2 = new StructStat(/*st_dev*/ 0L, /*st_ino*/ 0L, /*st_mode*/ 0, + /*st_nlink*/ 1L, /*st_uid*/ 1000, /*st_gid*/ 1000, /*st_rdev*/ 0L, /*st_size*/ 0L, + /*st_atim*/ new StructTimespec(0L, 0L), /*st_mtim*/ new StructTimespec(0L, 0L), + /*st_ctim*/ new StructTimespec(0L, 0L), /*st_blksize*/ 4096L, /*st_blocks*/ 1L); + assertStructStatsEqual(structStat1, structStat2); + } + + @Test public void test_getrlimit() throws Exception { StructRlimit rlimit = Os.getrlimit(OsConstants.RLIMIT_NOFILE); // We can't really make any assertions about these values since they might vary from @@ -2069,4 +2083,23 @@ public class OsTest { expectException(() -> Os.memfd_create("test_memfd", 0xffff), ErrnoException.class, EINVAL, "memfd_create(\"test_memfd\", 0xffff)"); } + + private static void assertStructStatsEqual(StructStat expected, StructStat actual) { + assertEquals(expected.st_dev, actual.st_dev); + assertEquals(expected.st_ino, actual.st_ino); + assertEquals(expected.st_mode, actual.st_mode); + assertEquals(expected.st_nlink, actual.st_nlink); + assertEquals(expected.st_uid, actual.st_uid); + assertEquals(expected.st_gid, actual.st_gid); + assertEquals(expected.st_rdev, actual.st_rdev); + assertEquals(expected.st_size, actual.st_size); + assertEquals(expected.st_atime, actual.st_atime); + assertEquals(expected.st_atim, actual.st_atim); + assertEquals(expected.st_mtime, actual.st_mtime); + assertEquals(expected.st_mtim, actual.st_mtim); + assertEquals(expected.st_ctime, actual.st_ctime); + assertEquals(expected.st_ctim, actual.st_ctim); + assertEquals(expected.st_blksize, actual.st_blksize); + assertEquals(expected.st_blocks, actual.st_blocks); + } } |