Fix CopyEfsTest for symlinks

Use the -L flag to preserve symlinks.
Fixed various flags to ensure we handle symlinks right,
and adjusted the awk string to handle difference in how dates are
represented.

Test: atest CopyEfsTest
Flag: TEST_ONLY
Bug: 352567354
Change-Id: I686c16fc1d771bf00bdc7465beb29a91eaef9e46
This commit is contained in:
Daniel Rosenberg 2024-07-15 18:42:15 -07:00
parent e32a7f759b
commit 069a8098b3

View file

@ -69,15 +69,22 @@ public class CopyEfsTest extends BaseHostJUnit4Test {
r = getDevice().executeShellV2Command("umount /data/local/tmp/efs_test/mnt"); r = getDevice().executeShellV2Command("umount /data/local/tmp/efs_test/mnt");
assertEquals(r.getExitCode().intValue(), 0); assertEquals(r.getExitCode().intValue(), 0);
r = getDevice().executeShellV2Command(String.format("dump.f2fs -rfPo /data/local/tmp/efs_test/dump /data/local/tmp/efs_test/%s.img", name)); r = getDevice().executeShellV2Command(String.format("dump.f2fs -rfPLo /data/local/tmp/efs_test/dump /data/local/tmp/efs_test/%s.img", name));
assertEquals(r.getExitCode().intValue(), 0); assertEquals(r.getExitCode().intValue(), 0);
r = getDevice().executeShellV2Command(String.format("mount -r /data/local/tmp/efs_test/%s.img /data/local/tmp/efs_test/mnt", name)); r = getDevice().executeShellV2Command(String.format("mount -r /data/local/tmp/efs_test/%s.img /data/local/tmp/efs_test/mnt", name));
assertEquals(r.getExitCode().intValue(), 0); assertEquals(r.getExitCode().intValue(), 0);
assertEquals("", getDevice().executeShellCommand("diff -rq /data/local/tmp/efs_test/mnt /data/local/tmp/efs_test/dump")); r = getDevice().executeShellV2Command("diff -rq --no-dereference /data/local/tmp/efs_test/mnt /data/local/tmp/efs_test/dump");
// Remove timestamps at positions 6 and 7, because ls on device does not support --time-style assertEquals(r.getExitCode().intValue(), 0);
assertEquals(r.getStdout(), "");
// Remove timestamps because ls on device does not support --time-style. This is AWKward.
// Format is [permissions] [links] [uid] [gid] [size] time [name/symlink]
// time may have different numbers of blocks
// symlinks will be of the form a -> b
// So we can check for -> in the second to last spot to determine what position the timestamp ends at
// Remove totals because on disk block usage may change depending on filesystem // Remove totals because on disk block usage may change depending on filesystem
String ls_cmd = "cd /data/local/tmp/efs_test/%s;ls -AlLnR . | awk {'$6=\"\";$7=\"\";if ($1 != \"total\"){print $0}'}"; String ls_cmd = "cd /data/local/tmp/efs_test/%s;ls -AlnR . | awk {'if (NF>3 && $(NF-1) == \"->\") end=3; else end=1; for(i=6;i<=NF-end && i>0;i++)$i=\"\";if ($1 != \"total\"){print $0}'}";
String mnt_ls = getDevice().executeShellCommand(String.format(ls_cmd, "mnt")); String mnt_ls = getDevice().executeShellCommand(String.format(ls_cmd, "mnt"));
assertEquals(getDevice().executeShellCommand("echo $?"), "0\n"); assertEquals(getDevice().executeShellCommand("echo $?"), "0\n");
String dump_ls = getDevice().executeShellCommand(String.format(ls_cmd, "dump")); String dump_ls = getDevice().executeShellCommand(String.format(ls_cmd, "dump"));