(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestDropWritesExt4(t *testing.T) { |
| 58 | flakey, root := initFlakey(t, FSTypeEXT4) |
| 59 | |
| 60 | // commit=1000 is to delay commit triggered by writeback thread |
| 61 | require.NoError(t, mount(root, flakey.DevicePath(), "commit=1000")) |
| 62 | |
| 63 | // ensure testdir/f1 is synced. |
| 64 | target := filepath.Join(root, "testdir") |
| 65 | require.NoError(t, os.MkdirAll(target, 0600)) |
| 66 | |
| 67 | f1 := filepath.Join(target, "f1") |
| 68 | assert.NoError(t, writeFile(f1, []byte("hello, world from f1"), 0600, false)) |
| 69 | require.NoError(t, syncfs(f1)) |
| 70 | |
| 71 | // testdir/f2 is created but without fsync |
| 72 | f2 := filepath.Join(target, "f2") |
| 73 | assert.NoError(t, writeFile(f2, []byte("hello, world from f2"), 0600, false)) |
| 74 | |
| 75 | // simulate power failure |
| 76 | assert.NoError(t, flakey.DropWrites()) |
| 77 | assert.NoError(t, unmount(root)) |
| 78 | assert.NoError(t, flakey.AllowWrites()) |
| 79 | require.NoError(t, mount(root, flakey.DevicePath(), "")) |
| 80 | |
| 81 | data, err := os.ReadFile(f1) |
| 82 | assert.NoError(t, err) |
| 83 | assert.Equal(t, "hello, world from f1", string(data)) |
| 84 | |
| 85 | _, err = os.ReadFile(f2) |
| 86 | assert.True(t, errors.Is(err, os.ErrNotExist)) |
| 87 | } |
| 88 | |
| 89 | func TestErrorWritesExt4(t *testing.T) { |
| 90 | flakey, root := initFlakey(t, FSTypeEXT4) |
nothing calls this directly
no test coverage detected