| ... | @@ -276,8 +276,11 @@ test "mmap" { | ... | @@ -276,8 +276,11 @@ test "mmap" { |
| 276 | testing.expectEqual(@as(usize, 1234), data.len); | 276 | testing.expectEqual(@as(usize, 1234), data.len); |
| 277 | | 277 | |
| 278 | // By definition the data returned by mmap is zero-filled | 278 | // By definition the data returned by mmap is zero-filled |
| 279 | std.mem.set(u8, data[0 .. data.len - 1], 0x55); | 279 | testing.expect(mem.eql(u8, data, &[_]u8{0x00} ** 1234)); |
| 280 | testing.expect(mem.indexOfScalar(u8, data, 0).? == 1234 - 1); | 280 | |
| | 281 | // Make sure the memory is writeable as requested |
| | 282 | std.mem.set(u8, data, 0x55); |
| | 283 | testing.expect(mem.eql(u8, data, &[_]u8{0x55} ** 1234)); |
| 281 | } | 284 | } |
| 282 | | 285 | |
| 283 | const test_out_file = "os_tmp_test"; | 286 | const test_out_file = "os_tmp_test"; |
| ... | @@ -300,10 +303,7 @@ test "mmap" { | ... | @@ -300,10 +303,7 @@ test "mmap" { |
| 300 | | 303 | |
| 301 | // Map the whole file | 304 | // Map the whole file |
| 302 | { | 305 | { |
| 303 | const file = try fs.cwd().createFile(test_out_file, .{ | 306 | const file = try fs.cwd().openFile(test_out_file, .{}); |
| 304 | .read = true, | | |
| 305 | .truncate = false, | | |
| 306 | }); | | |
| 307 | defer file.close(); | 307 | defer file.close(); |
| 308 | | 308 | |
| 309 | const data = try os.mmap( | 309 | const data = try os.mmap( |
| ... | @@ -327,15 +327,12 @@ test "mmap" { | ... | @@ -327,15 +327,12 @@ test "mmap" { |
| 327 | | 327 | |
| 328 | // Map the upper half of the file | 328 | // Map the upper half of the file |
| 329 | { | 329 | { |
| 330 | const file = try fs.cwd().createFile(test_out_file, .{ | 330 | const file = try fs.cwd().openFile(test_out_file, .{}); |
| 331 | .read = true, | | |
| 332 | .truncate = false, | | |
| 333 | }); | | |
| 334 | defer file.close(); | 331 | defer file.close(); |
| 335 | | 332 | |
| 336 | const data = try os.mmap( | 333 | const data = try os.mmap( |
| 337 | null, | 334 | null, |
| 338 | alloc_size, | 335 | alloc_size / 2, |
| 339 | os.PROT_READ, | 336 | os.PROT_READ, |
| 340 | os.MAP_PRIVATE, | 337 | os.MAP_PRIVATE, |
| 341 | file.handle, | 338 | file.handle, |