(base *testutil.Base, catPath string, fileContent []byte, container string, expectedUID int, containerIsStopped bool)
| 808 | } |
| 809 | |
| 810 | func assertCatHelper(base *testutil.Base, catPath string, fileContent []byte, container string, expectedUID int, containerIsStopped bool) { |
| 811 | base.T.Logf("catPath=%q", catPath) |
| 812 | if container != "" && containerIsStopped { |
| 813 | base.Cmd("start", container).AssertOK() |
| 814 | defer base.Cmd("stop", container).AssertOK() |
| 815 | } |
| 816 | |
| 817 | if container == "" { |
| 818 | got, err := os.ReadFile(catPath) |
| 819 | assert.NilError(base.T, err, "Failed reading from file") |
| 820 | assert.DeepEqual(base.T, fileContent, got) |
| 821 | st, err := os.Stat(catPath) |
| 822 | assert.NilError(base.T, err) |
| 823 | stSys := st.Sys().(*syscall.Stat_t) |
| 824 | expected := uint32(expectedUID) |
| 825 | actual := stSys.Uid |
| 826 | assert.DeepEqual(base.T, expected, actual) |
| 827 | } else { |
| 828 | base.Cmd("exec", container, "sh", "-c", "--", fmt.Sprintf("ls -lA /; echo %q; cat %q", catPath, catPath)).AssertOutContains(string(fileContent)) |
| 829 | base.Cmd("exec", container, "stat", "-c", "%u", catPath).AssertOutExactly(fmt.Sprintf("%d\n", expectedUID)) |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | func cpTestHelper(t *testing.T, tg *testgroup) { |
| 834 | // Get the source path |
no test coverage detected
searching dependent graphs…