summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/filesys/base
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
committermanuel <manuel@mausz.at>2012-03-26 12:54:45 +0200
commitb5f0874cd96ee2a62aabc645b9626c2749cb6a01 (patch)
tree1262e4bbe0634de6650be130c36e0538240f4cbf /pintos-progos/tests/filesys/base
downloadprogos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.gz
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.tar.bz2
progos-b5f0874cd96ee2a62aabc645b9626c2749cb6a01.zip
initial pintos checkin
Diffstat (limited to 'pintos-progos/tests/filesys/base')
-rw-r--r--pintos-progos/tests/filesys/base/Make.tests18
-rw-r--r--pintos-progos/tests/filesys/base/Rubric19
-rw-r--r--pintos-progos/tests/filesys/base/child-syn-read.c44
-rw-r--r--pintos-progos/tests/filesys/base/child-syn-wrt.c35
-rw-r--r--pintos-progos/tests/filesys/base/full.inc20
-rw-r--r--pintos-progos/tests/filesys/base/lg-create.c5
-rw-r--r--pintos-progos/tests/filesys/base/lg-create.ck13
-rw-r--r--pintos-progos/tests/filesys/base/lg-full.c6
-rw-r--r--pintos-progos/tests/filesys/base/lg-full.ck16
-rw-r--r--pintos-progos/tests/filesys/base/lg-random.c7
-rw-r--r--pintos-progos/tests/filesys/base/lg-random.ck14
-rw-r--r--pintos-progos/tests/filesys/base/lg-seq-block.c7
-rw-r--r--pintos-progos/tests/filesys/base/lg-seq-block.ck16
-rw-r--r--pintos-progos/tests/filesys/base/lg-seq-random.c6
-rw-r--r--pintos-progos/tests/filesys/base/lg-seq-random.ck16
-rw-r--r--pintos-progos/tests/filesys/base/random.inc59
-rw-r--r--pintos-progos/tests/filesys/base/seq-block.inc20
-rw-r--r--pintos-progos/tests/filesys/base/seq-random.inc22
-rw-r--r--pintos-progos/tests/filesys/base/sm-create.c5
-rw-r--r--pintos-progos/tests/filesys/base/sm-create.ck13
-rw-r--r--pintos-progos/tests/filesys/base/sm-full.c6
-rw-r--r--pintos-progos/tests/filesys/base/sm-full.ck16
-rw-r--r--pintos-progos/tests/filesys/base/sm-random.c7
-rw-r--r--pintos-progos/tests/filesys/base/sm-random.ck14
-rw-r--r--pintos-progos/tests/filesys/base/sm-seq-block.c7
-rw-r--r--pintos-progos/tests/filesys/base/sm-seq-block.ck16
-rw-r--r--pintos-progos/tests/filesys/base/sm-seq-random.c6
-rw-r--r--pintos-progos/tests/filesys/base/sm-seq-random.ck16
-rw-r--r--pintos-progos/tests/filesys/base/syn-read.c31
-rw-r--r--pintos-progos/tests/filesys/base/syn-read.ck33
-rw-r--r--pintos-progos/tests/filesys/base/syn-read.h7
-rw-r--r--pintos-progos/tests/filesys/base/syn-remove.c30
-rw-r--r--pintos-progos/tests/filesys/base/syn-remove.ck16
-rw-r--r--pintos-progos/tests/filesys/base/syn-write.c31
-rw-r--r--pintos-progos/tests/filesys/base/syn-write.ck32
-rw-r--r--pintos-progos/tests/filesys/base/syn-write.h9
36 files changed, 638 insertions, 0 deletions
diff --git a/pintos-progos/tests/filesys/base/Make.tests b/pintos-progos/tests/filesys/base/Make.tests
new file mode 100644
index 0000000..e475222
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/Make.tests
@@ -0,0 +1,18 @@
1# -*- makefile -*-
2
3tests/filesys/base_TESTS = $(addprefix tests/filesys/base/,lg-create \
4lg-full lg-random lg-seq-block lg-seq-random sm-create sm-full \
5sm-random sm-seq-block sm-seq-random syn-read syn-remove syn-write)
6
7tests/filesys/base_PROGS = $(tests/filesys/base_TESTS) $(addprefix \
8tests/filesys/base/,child-syn-read child-syn-wrt)
9
10$(foreach prog,$(tests/filesys/base_PROGS), \
11 $(eval $(prog)_SRC += $(prog).c tests/lib.c tests/filesys/seq-test.c))
12$(foreach prog,$(tests/filesys/base_TESTS), \
13 $(eval $(prog)_SRC += tests/main.c))
14
15tests/filesys/base/syn-read_PUTFILES = tests/filesys/base/child-syn-read
16tests/filesys/base/syn-write_PUTFILES = tests/filesys/base/child-syn-wrt
17
18tests/filesys/base/syn-read.output: TIMEOUT = 300
diff --git a/pintos-progos/tests/filesys/base/Rubric b/pintos-progos/tests/filesys/base/Rubric
new file mode 100644
index 0000000..49a9d15
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/Rubric
@@ -0,0 +1,19 @@
1Functionality of base file system:
2- Test basic support for small files.
31 sm-create
42 sm-full
52 sm-random
62 sm-seq-block
73 sm-seq-random
8
9- Test basic support for large files.
101 lg-create
112 lg-full
122 lg-random
132 lg-seq-block
143 lg-seq-random
15
16- Test synchronized multiprogram access to files.
174 syn-read
184 syn-write
192 syn-remove
diff --git a/pintos-progos/tests/filesys/base/child-syn-read.c b/pintos-progos/tests/filesys/base/child-syn-read.c
new file mode 100644
index 0000000..77a5e26
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/child-syn-read.c
@@ -0,0 +1,44 @@
1/* Child process for syn-read test.
2 Reads the contents of a test file a byte at a time, in the
3 hope that this will take long enough that we can get a
4 significant amount of contention in the kernel file system
5 code. */
6
7#include <random.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <syscall.h>
11#include "tests/lib.h"
12#include "tests/filesys/base/syn-read.h"
13
14const char *test_name = "child-syn-read";
15
16static char buf[BUF_SIZE];
17
18int
19main (int argc, const char *argv[])
20{
21 int child_idx;
22 int fd;
23 size_t i;
24
25 quiet = true;
26
27 CHECK (argc == 2, "argc must be 2, actually %d", argc);
28 child_idx = atoi (argv[1]);
29
30 random_init (0);
31 random_bytes (buf, sizeof buf);
32
33 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
34 for (i = 0; i < sizeof buf; i++)
35 {
36 char c;
37 CHECK (read (fd, &c, 1) > 0, "read \"%s\"", file_name);
38 compare_bytes (&c, buf + i, 1, i, file_name);
39 }
40 close (fd);
41
42 return child_idx;
43}
44
diff --git a/pintos-progos/tests/filesys/base/child-syn-wrt.c b/pintos-progos/tests/filesys/base/child-syn-wrt.c
new file mode 100644
index 0000000..1b52584
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/child-syn-wrt.c
@@ -0,0 +1,35 @@
1/* Child process for syn-read test.
2 Writes into part of a test file. Other processes will be
3 writing into other parts at the same time. */
4
5#include <random.h>
6#include <stdlib.h>
7#include <syscall.h>
8#include "tests/lib.h"
9#include "tests/filesys/base/syn-write.h"
10
11char buf[BUF_SIZE];
12
13int
14main (int argc, char *argv[])
15{
16 int child_idx;
17 int fd;
18
19 quiet = true;
20
21 CHECK (argc == 2, "argc must be 2, actually %d", argc);
22 child_idx = atoi (argv[1]);
23
24 random_init (0);
25 random_bytes (buf, sizeof buf);
26
27 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
28 seek (fd, CHUNK_SIZE * child_idx);
29 CHECK (write (fd, buf + CHUNK_SIZE * child_idx, CHUNK_SIZE) > 0,
30 "write \"%s\"", file_name);
31 msg ("close \"%s\"", file_name);
32 close (fd);
33
34 return child_idx;
35}
diff --git a/pintos-progos/tests/filesys/base/full.inc b/pintos-progos/tests/filesys/base/full.inc
new file mode 100644
index 0000000..38a0396
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/full.inc
@@ -0,0 +1,20 @@
1/* -*- c -*- */
2
3#include "tests/filesys/seq-test.h"
4#include "tests/main.h"
5
6static char buf[TEST_SIZE];
7
8static size_t
9return_test_size (void)
10{
11 return TEST_SIZE;
12}
13
14void
15test_main (void)
16{
17 seq_test ("quux",
18 buf, sizeof buf, sizeof buf,
19 return_test_size, NULL);
20}
diff --git a/pintos-progos/tests/filesys/base/lg-create.c b/pintos-progos/tests/filesys/base/lg-create.c
new file mode 100644
index 0000000..5c45eee
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-create.c
@@ -0,0 +1,5 @@
1/* Tests that create properly zeros out the contents of a fairly
2 large file. */
3
4#define TEST_SIZE 75678
5#include "tests/filesys/create.inc"
diff --git a/pintos-progos/tests/filesys/base/lg-create.ck b/pintos-progos/tests/filesys/base/lg-create.ck
new file mode 100644
index 0000000..86b2c51
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-create.ck
@@ -0,0 +1,13 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(lg-create) begin
7(lg-create) create "blargle"
8(lg-create) open "blargle" for verification
9(lg-create) verified contents of "blargle"
10(lg-create) close "blargle"
11(lg-create) end
12EOF
13pass;
diff --git a/pintos-progos/tests/filesys/base/lg-full.c b/pintos-progos/tests/filesys/base/lg-full.c
new file mode 100644
index 0000000..5f7234d
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-full.c
@@ -0,0 +1,6 @@
1/* Writes out the contents of a fairly large file all at once,
2 and then reads it back to make sure that it was written
3 properly. */
4
5#define TEST_SIZE 75678
6#include "tests/filesys/base/full.inc"
diff --git a/pintos-progos/tests/filesys/base/lg-full.ck b/pintos-progos/tests/filesys/base/lg-full.ck
new file mode 100644
index 0000000..ee6c7f9
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-full.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(lg-full) begin
7(lg-full) create "quux"
8(lg-full) open "quux"
9(lg-full) writing "quux"
10(lg-full) close "quux"
11(lg-full) open "quux" for verification
12(lg-full) verified contents of "quux"
13(lg-full) close "quux"
14(lg-full) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/lg-random.c b/pintos-progos/tests/filesys/base/lg-random.c
new file mode 100644
index 0000000..b6f8873
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-random.c
@@ -0,0 +1,7 @@
1/* Writes out the content of a fairly large file in random order,
2 then reads it back in random order to verify that it was
3 written properly. */
4
5#define BLOCK_SIZE 512
6#define TEST_SIZE (512 * 150)
7#include "tests/filesys/base/random.inc"
diff --git a/pintos-progos/tests/filesys/base/lg-random.ck b/pintos-progos/tests/filesys/base/lg-random.ck
new file mode 100644
index 0000000..dd9f1dd
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-random.ck
@@ -0,0 +1,14 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(lg-random) begin
7(lg-random) create "bazzle"
8(lg-random) open "bazzle"
9(lg-random) write "bazzle" in random order
10(lg-random) read "bazzle" in random order
11(lg-random) close "bazzle"
12(lg-random) end
13EOF
14pass;
diff --git a/pintos-progos/tests/filesys/base/lg-seq-block.c b/pintos-progos/tests/filesys/base/lg-seq-block.c
new file mode 100644
index 0000000..580c30b
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-seq-block.c
@@ -0,0 +1,7 @@
1/* Writes out a fairly large file sequentially, one fixed-size
2 block at a time, then reads it back to verify that it was
3 written properly. */
4
5#define TEST_SIZE 75678
6#define BLOCK_SIZE 513
7#include "tests/filesys/base/seq-block.inc"
diff --git a/pintos-progos/tests/filesys/base/lg-seq-block.ck b/pintos-progos/tests/filesys/base/lg-seq-block.ck
new file mode 100644
index 0000000..b789081
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-seq-block.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(lg-seq-block) begin
7(lg-seq-block) create "noodle"
8(lg-seq-block) open "noodle"
9(lg-seq-block) writing "noodle"
10(lg-seq-block) close "noodle"
11(lg-seq-block) open "noodle" for verification
12(lg-seq-block) verified contents of "noodle"
13(lg-seq-block) close "noodle"
14(lg-seq-block) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/lg-seq-random.c b/pintos-progos/tests/filesys/base/lg-seq-random.c
new file mode 100644
index 0000000..fbb6bba
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-seq-random.c
@@ -0,0 +1,6 @@
1/* Writes out a fairly large file sequentially, one random-sized
2 block at a time, then reads it back to verify that it was
3 written properly. */
4
5#define TEST_SIZE 75678
6#include "tests/filesys/base/seq-random.inc"
diff --git a/pintos-progos/tests/filesys/base/lg-seq-random.ck b/pintos-progos/tests/filesys/base/lg-seq-random.ck
new file mode 100644
index 0000000..6b2dc82
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/lg-seq-random.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(lg-seq-random) begin
7(lg-seq-random) create "nibble"
8(lg-seq-random) open "nibble"
9(lg-seq-random) writing "nibble"
10(lg-seq-random) close "nibble"
11(lg-seq-random) open "nibble" for verification
12(lg-seq-random) verified contents of "nibble"
13(lg-seq-random) close "nibble"
14(lg-seq-random) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/random.inc b/pintos-progos/tests/filesys/base/random.inc
new file mode 100644
index 0000000..eeeea68
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/random.inc
@@ -0,0 +1,59 @@
1/* -*- c -*- */
2
3#include <random.h>
4#include <stdio.h>
5#include <string.h>
6#include <syscall.h>
7#include "tests/lib.h"
8#include "tests/main.h"
9
10#if TEST_SIZE % BLOCK_SIZE != 0
11#error TEST_SIZE must be a multiple of BLOCK_SIZE
12#endif
13
14#define BLOCK_CNT (TEST_SIZE / BLOCK_SIZE)
15
16char buf[TEST_SIZE];
17int order[BLOCK_CNT];
18
19void
20test_main (void)
21{
22 const char *file_name = "bazzle";
23 int fd;
24 size_t i;
25
26 random_init (57);
27 random_bytes (buf, sizeof buf);
28
29 for (i = 0; i < BLOCK_CNT; i++)
30 order[i] = i;
31
32 CHECK (create (file_name, TEST_SIZE), "create \"%s\"", file_name);
33 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
34
35 msg ("write \"%s\" in random order", file_name);
36 shuffle (order, BLOCK_CNT, sizeof *order);
37 for (i = 0; i < BLOCK_CNT; i++)
38 {
39 size_t ofs = BLOCK_SIZE * order[i];
40 seek (fd, ofs);
41 if (write (fd, buf + ofs, BLOCK_SIZE) != BLOCK_SIZE)
42 fail ("write %d bytes at offset %zu failed", (int) BLOCK_SIZE, ofs);
43 }
44
45 msg ("read \"%s\" in random order", file_name);
46 shuffle (order, BLOCK_CNT, sizeof *order);
47 for (i = 0; i < BLOCK_CNT; i++)
48 {
49 char block[BLOCK_SIZE];
50 size_t ofs = BLOCK_SIZE * order[i];
51 seek (fd, ofs);
52 if (read (fd, block, BLOCK_SIZE) != BLOCK_SIZE)
53 fail ("read %d bytes at offset %zu failed", (int) BLOCK_SIZE, ofs);
54 compare_bytes (block, buf + ofs, BLOCK_SIZE, ofs, file_name);
55 }
56
57 msg ("close \"%s\"", file_name);
58 close (fd);
59}
diff --git a/pintos-progos/tests/filesys/base/seq-block.inc b/pintos-progos/tests/filesys/base/seq-block.inc
new file mode 100644
index 0000000..d4c1f57
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/seq-block.inc
@@ -0,0 +1,20 @@
1/* -*- c -*- */
2
3#include "tests/filesys/seq-test.h"
4#include "tests/main.h"
5
6static char buf[TEST_SIZE];
7
8static size_t
9return_block_size (void)
10{
11 return BLOCK_SIZE;
12}
13
14void
15test_main (void)
16{
17 seq_test ("noodle",
18 buf, sizeof buf, sizeof buf,
19 return_block_size, NULL);
20}
diff --git a/pintos-progos/tests/filesys/base/seq-random.inc b/pintos-progos/tests/filesys/base/seq-random.inc
new file mode 100644
index 0000000..a4da4c5
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/seq-random.inc
@@ -0,0 +1,22 @@
1/* -*- c -*- */
2
3#include <random.h>
4#include "tests/filesys/seq-test.h"
5#include "tests/main.h"
6
7static char buf[TEST_SIZE];
8
9static size_t
10return_random (void)
11{
12 return random_ulong () % 1031 + 1;
13}
14
15void
16test_main (void)
17{
18 random_init (-1);
19 seq_test ("nibble",
20 buf, sizeof buf, sizeof buf,
21 return_random, NULL);
22}
diff --git a/pintos-progos/tests/filesys/base/sm-create.c b/pintos-progos/tests/filesys/base/sm-create.c
new file mode 100644
index 0000000..6b97ac1
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-create.c
@@ -0,0 +1,5 @@
1/* Tests that create properly zeros out the contents of a fairly
2 small file. */
3
4#define TEST_SIZE 5678
5#include "tests/filesys/create.inc"
diff --git a/pintos-progos/tests/filesys/base/sm-create.ck b/pintos-progos/tests/filesys/base/sm-create.ck
new file mode 100644
index 0000000..8ca80dc
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-create.ck
@@ -0,0 +1,13 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(sm-create) begin
7(sm-create) create "blargle"
8(sm-create) open "blargle" for verification
9(sm-create) verified contents of "blargle"
10(sm-create) close "blargle"
11(sm-create) end
12EOF
13pass;
diff --git a/pintos-progos/tests/filesys/base/sm-full.c b/pintos-progos/tests/filesys/base/sm-full.c
new file mode 100644
index 0000000..23ff3d4
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-full.c
@@ -0,0 +1,6 @@
1/* Writes out the contents of a fairly small file all at once,
2 and then reads it back to make sure that it was written
3 properly. */
4
5#define TEST_SIZE 5678
6#include "tests/filesys/base/full.inc"
diff --git a/pintos-progos/tests/filesys/base/sm-full.ck b/pintos-progos/tests/filesys/base/sm-full.ck
new file mode 100644
index 0000000..2e0eb36
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-full.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(sm-full) begin
7(sm-full) create "quux"
8(sm-full) open "quux"
9(sm-full) writing "quux"
10(sm-full) close "quux"
11(sm-full) open "quux" for verification
12(sm-full) verified contents of "quux"
13(sm-full) close "quux"
14(sm-full) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/sm-random.c b/pintos-progos/tests/filesys/base/sm-random.c
new file mode 100644
index 0000000..42d670f
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-random.c
@@ -0,0 +1,7 @@
1/* Writes out the content of a fairly small file in random order,
2 then reads it back in random order to verify that it was
3 written properly. */
4
5#define BLOCK_SIZE 13
6#define TEST_SIZE (13 * 123)
7#include "tests/filesys/base/random.inc"
diff --git a/pintos-progos/tests/filesys/base/sm-random.ck b/pintos-progos/tests/filesys/base/sm-random.ck
new file mode 100644
index 0000000..bda049d
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-random.ck
@@ -0,0 +1,14 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(sm-random) begin
7(sm-random) create "bazzle"
8(sm-random) open "bazzle"
9(sm-random) write "bazzle" in random order
10(sm-random) read "bazzle" in random order
11(sm-random) close "bazzle"
12(sm-random) end
13EOF
14pass;
diff --git a/pintos-progos/tests/filesys/base/sm-seq-block.c b/pintos-progos/tests/filesys/base/sm-seq-block.c
new file mode 100644
index 0000000..e368327
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-seq-block.c
@@ -0,0 +1,7 @@
1/* Writes out a fairly small file sequentially, one fixed-size
2 block at a time, then reads it back to verify that it was
3 written properly. */
4
5#define TEST_SIZE 5678
6#define BLOCK_SIZE 513
7#include "tests/filesys/base/seq-block.inc"
diff --git a/pintos-progos/tests/filesys/base/sm-seq-block.ck b/pintos-progos/tests/filesys/base/sm-seq-block.ck
new file mode 100644
index 0000000..0e2939d
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-seq-block.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(sm-seq-block) begin
7(sm-seq-block) create "noodle"
8(sm-seq-block) open "noodle"
9(sm-seq-block) writing "noodle"
10(sm-seq-block) close "noodle"
11(sm-seq-block) open "noodle" for verification
12(sm-seq-block) verified contents of "noodle"
13(sm-seq-block) close "noodle"
14(sm-seq-block) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/sm-seq-random.c b/pintos-progos/tests/filesys/base/sm-seq-random.c
new file mode 100644
index 0000000..89e5b71
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-seq-random.c
@@ -0,0 +1,6 @@
1/* Writes out a fairly large file sequentially, one random-sized
2 block at a time, then reads it back to verify that it was
3 written properly. */
4
5#define TEST_SIZE 5678
6#include "tests/filesys/base/seq-random.inc"
diff --git a/pintos-progos/tests/filesys/base/sm-seq-random.ck b/pintos-progos/tests/filesys/base/sm-seq-random.ck
new file mode 100644
index 0000000..2fb368b
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/sm-seq-random.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(sm-seq-random) begin
7(sm-seq-random) create "nibble"
8(sm-seq-random) open "nibble"
9(sm-seq-random) writing "nibble"
10(sm-seq-random) close "nibble"
11(sm-seq-random) open "nibble" for verification
12(sm-seq-random) verified contents of "nibble"
13(sm-seq-random) close "nibble"
14(sm-seq-random) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/syn-read.c b/pintos-progos/tests/filesys/base/syn-read.c
new file mode 100644
index 0000000..7c36a42
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-read.c
@@ -0,0 +1,31 @@
1/* Spawns 10 child processes, all of which read from the same
2 file and make sure that the contents are what they should
3 be. */
4
5#include <random.h>
6#include <stdio.h>
7#include <syscall.h>
8#include "tests/lib.h"
9#include "tests/main.h"
10#include "tests/filesys/base/syn-read.h"
11
12static char buf[BUF_SIZE];
13
14#define CHILD_CNT 10
15
16void
17test_main (void)
18{
19 pid_t children[CHILD_CNT];
20 int fd;
21
22 CHECK (create (file_name, sizeof buf), "create \"%s\"", file_name);
23 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
24 random_bytes (buf, sizeof buf);
25 CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", file_name);
26 msg ("close \"%s\"", file_name);
27 close (fd);
28
29 exec_children ("child-syn-read", children, CHILD_CNT);
30 wait_children (children, CHILD_CNT);
31}
diff --git a/pintos-progos/tests/filesys/base/syn-read.ck b/pintos-progos/tests/filesys/base/syn-read.ck
new file mode 100644
index 0000000..e2f68e8
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-read.ck
@@ -0,0 +1,33 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(syn-read) begin
7(syn-read) create "data"
8(syn-read) open "data"
9(syn-read) write "data"
10(syn-read) close "data"
11(syn-read) exec child 1 of 10: "child-syn-read 0"
12(syn-read) exec child 2 of 10: "child-syn-read 1"
13(syn-read) exec child 3 of 10: "child-syn-read 2"
14(syn-read) exec child 4 of 10: "child-syn-read 3"
15(syn-read) exec child 5 of 10: "child-syn-read 4"
16(syn-read) exec child 6 of 10: "child-syn-read 5"
17(syn-read) exec child 7 of 10: "child-syn-read 6"
18(syn-read) exec child 8 of 10: "child-syn-read 7"
19(syn-read) exec child 9 of 10: "child-syn-read 8"
20(syn-read) exec child 10 of 10: "child-syn-read 9"
21(syn-read) wait for child 1 of 10 returned 0 (expected 0)
22(syn-read) wait for child 2 of 10 returned 1 (expected 1)
23(syn-read) wait for child 3 of 10 returned 2 (expected 2)
24(syn-read) wait for child 4 of 10 returned 3 (expected 3)
25(syn-read) wait for child 5 of 10 returned 4 (expected 4)
26(syn-read) wait for child 6 of 10 returned 5 (expected 5)
27(syn-read) wait for child 7 of 10 returned 6 (expected 6)
28(syn-read) wait for child 8 of 10 returned 7 (expected 7)
29(syn-read) wait for child 9 of 10 returned 8 (expected 8)
30(syn-read) wait for child 10 of 10 returned 9 (expected 9)
31(syn-read) end
32EOF
33pass;
diff --git a/pintos-progos/tests/filesys/base/syn-read.h b/pintos-progos/tests/filesys/base/syn-read.h
new file mode 100644
index 0000000..bff8082
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-read.h
@@ -0,0 +1,7 @@
1#ifndef TESTS_FILESYS_BASE_SYN_READ_H
2#define TESTS_FILESYS_BASE_SYN_READ_H
3
4#define BUF_SIZE 1024
5static const char file_name[] = "data";
6
7#endif /* tests/filesys/base/syn-read.h */
diff --git a/pintos-progos/tests/filesys/base/syn-remove.c b/pintos-progos/tests/filesys/base/syn-remove.c
new file mode 100644
index 0000000..c9ba110
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-remove.c
@@ -0,0 +1,30 @@
1/* Verifies that a deleted file may still be written to and read
2 from. */
3
4#include <random.h>
5#include <string.h>
6#include <syscall.h>
7#include "tests/lib.h"
8#include "tests/main.h"
9
10char buf1[1234];
11char buf2[1234];
12
13void
14test_main (void)
15{
16 const char *file_name = "deleteme";
17 int fd;
18
19 CHECK (create (file_name, sizeof buf1), "create \"%s\"", file_name);
20 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
21 CHECK (remove (file_name), "remove \"%s\"", file_name);
22 random_bytes (buf1, sizeof buf1);
23 CHECK (write (fd, buf1, sizeof buf1) > 0, "write \"%s\"", file_name);
24 msg ("seek \"%s\" to 0", file_name);
25 seek (fd, 0);
26 CHECK (read (fd, buf2, sizeof buf2) > 0, "read \"%s\"", file_name);
27 compare_bytes (buf2, buf1, sizeof buf1, 0, file_name);
28 msg ("close \"%s\"", file_name);
29 close (fd);
30}
diff --git a/pintos-progos/tests/filesys/base/syn-remove.ck b/pintos-progos/tests/filesys/base/syn-remove.ck
new file mode 100644
index 0000000..16ff11e
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-remove.ck
@@ -0,0 +1,16 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(syn-remove) begin
7(syn-remove) create "deleteme"
8(syn-remove) open "deleteme"
9(syn-remove) remove "deleteme"
10(syn-remove) write "deleteme"
11(syn-remove) seek "deleteme" to 0
12(syn-remove) read "deleteme"
13(syn-remove) close "deleteme"
14(syn-remove) end
15EOF
16pass;
diff --git a/pintos-progos/tests/filesys/base/syn-write.c b/pintos-progos/tests/filesys/base/syn-write.c
new file mode 100644
index 0000000..1439862
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-write.c
@@ -0,0 +1,31 @@
1/* Spawns several child processes to write out different parts of
2 the contents of a file and waits for them to finish. Then
3 reads back the file and verifies its contents. */
4
5#include <random.h>
6#include <stdio.h>
7#include <string.h>
8#include <syscall.h>
9#include "tests/filesys/base/syn-write.h"
10#include "tests/lib.h"
11#include "tests/main.h"
12
13char buf1[BUF_SIZE];
14char buf2[BUF_SIZE];
15
16void
17test_main (void)
18{
19 pid_t children[CHILD_CNT];
20 int fd;
21
22 CHECK (create (file_name, sizeof buf1), "create \"%s\"", file_name);
23
24 exec_children ("child-syn-wrt", children, CHILD_CNT);
25 wait_children (children, CHILD_CNT);
26
27 CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
28 CHECK (read (fd, buf1, sizeof buf1) > 0, "read \"%s\"", file_name);
29 random_bytes (buf2, sizeof buf2);
30 compare_bytes (buf1, buf2, sizeof buf1, 0, file_name);
31}
diff --git a/pintos-progos/tests/filesys/base/syn-write.ck b/pintos-progos/tests/filesys/base/syn-write.ck
new file mode 100644
index 0000000..629a7a2
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-write.ck
@@ -0,0 +1,32 @@
1# -*- perl -*-
2use strict;
3use warnings;
4use tests::tests;
5check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
6(syn-write) begin
7(syn-write) create "stuff"
8(syn-write) exec child 1 of 10: "child-syn-wrt 0"
9(syn-write) exec child 2 of 10: "child-syn-wrt 1"
10(syn-write) exec child 3 of 10: "child-syn-wrt 2"
11(syn-write) exec child 4 of 10: "child-syn-wrt 3"
12(syn-write) exec child 5 of 10: "child-syn-wrt 4"
13(syn-write) exec child 6 of 10: "child-syn-wrt 5"
14(syn-write) exec child 7 of 10: "child-syn-wrt 6"
15(syn-write) exec child 8 of 10: "child-syn-wrt 7"
16(syn-write) exec child 9 of 10: "child-syn-wrt 8"
17(syn-write) exec child 10 of 10: "child-syn-wrt 9"
18(syn-write) wait for child 1 of 10 returned 0 (expected 0)
19(syn-write) wait for child 2 of 10 returned 1 (expected 1)
20(syn-write) wait for child 3 of 10 returned 2 (expected 2)
21(syn-write) wait for child 4 of 10 returned 3 (expected 3)
22(syn-write) wait for child 5 of 10 returned 4 (expected 4)
23(syn-write) wait for child 6 of 10 returned 5 (expected 5)
24(syn-write) wait for child 7 of 10 returned 6 (expected 6)
25(syn-write) wait for child 8 of 10 returned 7 (expected 7)
26(syn-write) wait for child 9 of 10 returned 8 (expected 8)
27(syn-write) wait for child 10 of 10 returned 9 (expected 9)
28(syn-write) open "stuff"
29(syn-write) read "stuff"
30(syn-write) end
31EOF
32pass;
diff --git a/pintos-progos/tests/filesys/base/syn-write.h b/pintos-progos/tests/filesys/base/syn-write.h
new file mode 100644
index 0000000..07a6d5a
--- /dev/null
+++ b/pintos-progos/tests/filesys/base/syn-write.h
@@ -0,0 +1,9 @@
1#ifndef TESTS_FILESYS_BASE_SYN_WRITE_H
2#define TESTS_FILESYS_BASE_SYN_WRITE_H
3
4#define CHILD_CNT 10
5#define CHUNK_SIZE 512
6#define BUF_SIZE (CHILD_CNT * CHUNK_SIZE)
7static const char file_name[] = "stuff";
8
9#endif /* tests/filesys/base/syn-write.h */