Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / grading / filesys / random.inc
diff --git a/grading/filesys/random.inc b/grading/filesys/random.inc
deleted file mode 100644 (file)
index 895b658..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c -*- */
-
-#include <random.h>
-#include <stdio.h>
-#include <string.h>
-#include <syscall.h>
-#include "fslib.h"
-
-#if TEST_SIZE % BLOCK_SIZE != 0
-#error TEST_SIZE must be a multiple of BLOCK_SIZE
-#endif
-
-#define BLOCK_CNT (TEST_SIZE / BLOCK_SIZE)
-
-char buf[TEST_SIZE];
-int order[BLOCK_CNT];
-
-void
-test_main (void) 
-{
-  const char *filename = "bazzle";
-  int fd;
-  size_t i;
-
-  random_init (57);
-  random_bytes (buf, sizeof buf);
-
-  for (i = 0; i < BLOCK_CNT; i++)
-    order[i] = i;
-
-  CHECK (create (filename, TEST_SIZE), "create \"%s\"", filename);
-  CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
-
-  msg ("write \"%s\" in random order", filename);
-  shuffle (order, BLOCK_CNT, sizeof *order);
-  for (i = 0; i < BLOCK_CNT; i++) 
-    {
-      size_t ofs = BLOCK_SIZE * order[i];
-      seek (fd, ofs);
-      if (write (fd, buf + ofs, BLOCK_SIZE) <= 0)
-        fail ("write %d bytes at offset %zu failed", (int) BLOCK_SIZE, ofs);
-    }
-
-  msg ("read \"%s\" in random order", filename);
-  shuffle (order, BLOCK_CNT, sizeof *order);
-  for (i = 0; i < BLOCK_CNT; i++) 
-    {
-      char block[BLOCK_SIZE];
-      size_t ofs = BLOCK_SIZE * order[i];
-      seek (fd, ofs);
-      if (read (fd, block, BLOCK_SIZE) <= 0)
-        fail ("read %d bytes at offset %zu failed", (int) BLOCK_SIZE, ofs);
-      compare_bytes (block, buf + ofs, BLOCK_SIZE, ofs, filename);
-    }
-
-  msg ("close \"%s\"", filename);
-  close (fd);
-}