code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected ([<<'EOF']); (priority-donate-sema) begin (priority-donate-sema) Thread L acquired lock. (priority-donate-sema) Thread L downed semaphore. (priority-donate-sema) Thread H acquired lock. (priority-donate-sema) Thread H finished. (priority-donate-sema) Thread M finished. (priority-donate-sema) Thread L finished. (priority-donate-sema) Main thread finished. (priority-donate-sema) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/threads/priority-donate-sema.ck
Perl
oos
468
/* Checks that when the alarm clock wakes up threads, the higher-priority threads run first. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/malloc.h" #include "threads/synch.h" #include "threads/thread.h" #include "devices/timer.h" static thread_func alarm_priority_thread; static int64_t wake_time; static struct semaphore wait_sema; void test_alarm_priority (void) { int i; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); wake_time = timer_ticks () + 5 * TIMER_FREQ; sema_init (&wait_sema, 0); for (i = 0; i < 10; i++) { int priority = PRI_DEFAULT - (i + 5) % 10 - 1; char name[16]; snprintf (name, sizeof name, "priority %d", priority); thread_create (name, priority, alarm_priority_thread, NULL); } thread_set_priority (PRI_MIN); for (i = 0; i < 10; i++) sema_down (&wait_sema); } static void alarm_priority_thread (void *aux UNUSED) { /* Busy-wait until the current time changes. */ int64_t start_time = timer_ticks (); while (timer_elapsed (start_time) == 0) continue; /* Now we know we're at the very beginning of a timer tick, so we can call timer_sleep() without worrying about races between checking the time and a timer interrupt. */ timer_sleep (wake_time - timer_ticks ()); /* Prints a message on wake-up. */ msg ("Thread %s woke up.", thread_name ()); sema_up (&wait_sema); }
10cm
trunk/10cm/pintos/src/tests/threads/alarm-priority.c
C
oos
1,468
/* The main thread acquires a lock. Then it creates two higher-priority threads that block acquiring the lock, causing them to donate their priorities to the main thread. When the main thread releases the lock, the other threads should acquire it in priority order. Based on a test originally submitted for Stanford's CS 140 in winter 1999 by Matt Franklin <startled@leland.stanford.edu>, Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>. Modified by arens. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/synch.h" #include "threads/thread.h" static thread_func acquire1_thread_func; static thread_func acquire2_thread_func; void test_priority_donate_one (void) { struct lock lock; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); /* Make sure our priority is the default. */ ASSERT (thread_get_priority () == PRI_DEFAULT); lock_init (&lock); lock_acquire (&lock); thread_create ("acquire1", PRI_DEFAULT + 1, acquire1_thread_func, &lock); msg ("This thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 1, thread_get_priority ()); thread_create ("acquire2", PRI_DEFAULT + 2, acquire2_thread_func, &lock); msg ("This thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 2, thread_get_priority ()); lock_release (&lock); msg ("acquire2, acquire1 must already have finished, in that order."); msg ("This should be the last line before finishing this test."); } static void acquire1_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("acquire1: got the lock"); lock_release (lock); msg ("acquire1: done"); } static void acquire2_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("acquire2: got the lock"); lock_release (lock); msg ("acquire2: done"); }
10cm
trunk/10cm/pintos/src/tests/threads/priority-donate-one.c
C
oos
1,944
/* The main thread acquires a lock. Then it creates a higher-priority thread that blocks acquiring the lock, causing it to donate their priorities to the main thread. The main thread attempts to lower its priority, which should not take effect until the donation is released. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/synch.h" #include "threads/thread.h" static thread_func acquire_thread_func; void test_priority_donate_lower (void) { struct lock lock; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); /* Make sure our priority is the default. */ ASSERT (thread_get_priority () == PRI_DEFAULT); lock_init (&lock); lock_acquire (&lock); thread_create ("acquire", PRI_DEFAULT + 10, acquire_thread_func, &lock); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 10, thread_get_priority ()); msg ("Lowering base priority..."); thread_set_priority (PRI_DEFAULT - 10); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 10, thread_get_priority ()); lock_release (&lock); msg ("acquire must already have finished."); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT - 10, thread_get_priority ()); } static void acquire_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("acquire: got the lock"); lock_release (lock); msg ("acquire: done"); }
10cm
trunk/10cm/pintos/src/tests/threads/priority-donate-lower.c
C
oos
1,521
/* Tests timer_sleep(-100). Only requirement is that it not crash. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/malloc.h" #include "threads/synch.h" #include "threads/thread.h" #include "devices/timer.h" void test_alarm_negative (void) { timer_sleep (-100); pass (); }
10cm
trunk/10cm/pintos/src/tests/threads/alarm-negative.c
C
oos
305
# -*- perl -*- use tests::tests; use tests::threads::alarm; check_alarm (7);
10cm
trunk/10cm/pintos/src/tests/threads/alarm-multiple.ck
Perl
oos
77
/* Tests that the highest-priority thread waiting on a semaphore is the first to wake up. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/malloc.h" #include "threads/synch.h" #include "threads/thread.h" #include "devices/timer.h" static thread_func priority_sema_thread; static struct semaphore sema; void test_priority_sema (void) { int i; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); sema_init (&sema, 0); thread_set_priority (PRI_MIN); for (i = 0; i < 10; i++) { int priority = PRI_DEFAULT - (i + 3) % 10 - 1; char name[16]; snprintf (name, sizeof name, "priority %d", priority); thread_create (name, priority, priority_sema_thread, NULL); } for (i = 0; i < 10; i++) { sema_up (&sema); msg ("Back in main thread."); } } static void priority_sema_thread (void *aux UNUSED) { sema_down (&sema); msg ("Thread %s woke up.", thread_name ()); }
10cm
trunk/10cm/pintos/src/tests/threads/priority-sema.c
C
oos
1,005
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::threads::mlfqs; our ($test); my (@output) = read_text_file ("$test.output"); common_checks ("run", @output); @output = get_core_output ("run", @output); # Get actual values. local ($_); my (@actual); foreach (@output) { my ($t, $load_avg) = /After (\d+) seconds, load average=(\d+\.\d+)\./ or next; $actual[$t] = $load_avg; } # Calculate expected values. my ($load_avg) = 0; my ($recent) = 0; my (@expected); for (my ($t) = 0; $t < 180; $t++) { my ($ready) = $t < 60 ? 60 : 0; $load_avg = (59/60) * $load_avg + (1/60) * $ready; $expected[$t] = $load_avg; } mlfqs_compare ("time", "%.2f", \@actual, \@expected, 3.5, [2, 178, 2], "Some load average values were missing or " . "differed from those expected " . "by more than 3.5."); pass;
10cm
trunk/10cm/pintos/src/tests/threads/mlfqs-load-60.ck
Perl
oos
861
sub check_alarm { my ($iterations) = @_; our ($test); @output = read_text_file ("$test.output"); common_checks ("run", @output); my (@products); for (my ($i) = 0; $i < $iterations; $i++) { for (my ($t) = 0; $t < 5; $t++) { push (@products, ($i + 1) * ($t + 1) * 10); } } @products = sort {$a <=> $b} @products; local ($_); foreach (@output) { fail $_ if /out of order/i; my ($p) = /product=(\d+)$/; next if !defined $p; my ($q) = shift (@products); fail "Too many wakeups.\n" if !defined $q; fail "Out of order wakeups ($p vs. $q).\n" if $p != $q; # FIXME } fail scalar (@products) . " fewer wakeups than expected.\n" if @products != 0; pass; } 1;
10cm
trunk/10cm/pintos/src/tests/threads/alarm.pm
Raku
oos
725
/* Measures the correctness of the "nice" implementation. The "fair" tests run either 2 or 20 threads all niced to 0. The threads should all receive approximately the same number of ticks. Each test runs for 30 seconds, so the ticks should also sum to approximately 30 * 100 == 3000 ticks. The mlfqs-nice-2 test runs 2 threads, one with nice 0, the other with nice 5, which should receive 1,904 and 1,096 ticks, respectively, over 30 seconds. The mlfqs-nice-10 test runs 10 threads with nice 0 through 9. They should receive 672, 588, 492, 408, 316, 232, 152, 92, 40, and 8 ticks, respectively, over 30 seconds. (The above are computed via simulation in mlfqs.pm.) */ #include <stdio.h> #include <inttypes.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/malloc.h" #include "threads/palloc.h" #include "threads/synch.h" #include "threads/thread.h" #include "devices/timer.h" static void test_mlfqs_fair (int thread_cnt, int nice_min, int nice_step); void test_mlfqs_fair_2 (void) { test_mlfqs_fair (2, 0, 0); } void test_mlfqs_fair_20 (void) { test_mlfqs_fair (20, 0, 0); } void test_mlfqs_nice_2 (void) { test_mlfqs_fair (2, 0, 5); } void test_mlfqs_nice_10 (void) { test_mlfqs_fair (10, 0, 1); } #define MAX_THREAD_CNT 20 struct thread_info { int64_t start_time; int tick_count; int nice; }; static void load_thread (void *aux); static void test_mlfqs_fair (int thread_cnt, int nice_min, int nice_step) { struct thread_info info[MAX_THREAD_CNT]; int64_t start_time; int nice; int i; ASSERT (thread_mlfqs); ASSERT (thread_cnt <= MAX_THREAD_CNT); ASSERT (nice_min >= -10); ASSERT (nice_step >= 0); ASSERT (nice_min + nice_step * (thread_cnt - 1) <= 20); thread_set_nice (-20); start_time = timer_ticks (); msg ("Starting %d threads...", thread_cnt); nice = nice_min; for (i = 0; i < thread_cnt; i++) { struct thread_info *ti = &info[i]; char name[16]; ti->start_time = start_time; ti->tick_count = 0; ti->nice = nice; snprintf(name, sizeof name, "load %d", i); thread_create (name, PRI_DEFAULT, load_thread, ti); nice += nice_step; } msg ("Starting threads took %"PRId64" ticks.", timer_elapsed (start_time)); msg ("Sleeping 40 seconds to let threads run, please wait..."); timer_sleep (40 * TIMER_FREQ); for (i = 0; i < thread_cnt; i++) msg ("Thread %d received %d ticks.", i, info[i].tick_count); } static void load_thread (void *ti_) { struct thread_info *ti = ti_; int64_t sleep_time = 5 * TIMER_FREQ; int64_t spin_time = sleep_time + 30 * TIMER_FREQ; int64_t last_time = 0; thread_set_nice (ti->nice); timer_sleep (sleep_time - timer_elapsed (ti->start_time)); while (timer_elapsed (ti->start_time) < spin_time) { int64_t cur_time = timer_ticks (); if (cur_time != last_time) ti->tick_count++; last_time = cur_time; } }
10cm
trunk/10cm/pintos/src/tests/threads/mlfqs-fair.c
C
oos
2,993
/* The main thread acquires locks A and B, then it creates three higher-priority threads. The first two of these threads block acquiring one of the locks and thus donate their priority to the main thread. The main thread releases the locks in turn and relinquishes its donated priorities, allowing the third thread to run. In this test, the main thread releases the locks in a different order compared to priority-donate-multiple.c. Written by Godmar Back <gback@cs.vt.edu>. Based on a test originally submitted for Stanford's CS 140 in winter 1999 by Matt Franklin <startled@leland.stanford.edu>, Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>. Modified by arens. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/synch.h" #include "threads/thread.h" static thread_func a_thread_func; static thread_func b_thread_func; static thread_func c_thread_func; void test_priority_donate_multiple2 (void) { struct lock a, b; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); /* Make sure our priority is the default. */ ASSERT (thread_get_priority () == PRI_DEFAULT); lock_init (&a); lock_init (&b); lock_acquire (&a); lock_acquire (&b); thread_create ("a", PRI_DEFAULT + 3, a_thread_func, &a); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 3, thread_get_priority ()); thread_create ("c", PRI_DEFAULT + 1, c_thread_func, NULL); thread_create ("b", PRI_DEFAULT + 5, b_thread_func, &b); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 5, thread_get_priority ()); lock_release (&a); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT + 5, thread_get_priority ()); lock_release (&b); msg ("Threads b, a, c should have just finished, in that order."); msg ("Main thread should have priority %d. Actual priority: %d.", PRI_DEFAULT, thread_get_priority ()); } static void a_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("Thread a acquired lock a."); lock_release (lock); msg ("Thread a finished."); } static void b_thread_func (void *lock_) { struct lock *lock = lock_; lock_acquire (lock); msg ("Thread b acquired lock b."); lock_release (lock); msg ("Thread b finished."); } static void c_thread_func (void *a_ UNUSED) { msg ("Thread c finished."); }
10cm
trunk/10cm/pintos/src/tests/threads/priority-donate-multiple2.c
C
oos
2,520
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::threads::mlfqs; our ($test); my (@output) = read_text_file ("$test.output"); common_checks ("run", @output); @output = get_core_output ("run", @output); # Get actual values. local ($_); my (@actual); foreach (@output) { my ($t, $recent_cpu) = /After (\d+) seconds, recent_cpu is (\d+\.\d+),/ or next; $actual[$t] = $recent_cpu; } # Calculate expected values. my ($expected_load_avg, $expected_recent_cpu) = mlfqs_expected_load ([(1) x 180], [(100) x 180]); my (@expected) = @$expected_recent_cpu; # Compare actual and expected values. mlfqs_compare ("time", "%.2f", \@actual, \@expected, 2.5, [2, 178, 2], "Some recent_cpu values were missing or " . "differed from those expected " . "by more than 2.5."); pass;
10cm
trunk/10cm/pintos/src/tests/threads/mlfqs-recent-1.ck
Perl
oos
826
# -*- perl -*- use strict; use warnings; sub mlfqs_expected_load { my ($ready, $recent_delta) = @_; my (@load_avg) = 0; my (@recent_cpu) = 0; my ($load_avg) = 0; my ($recent_cpu) = 0; for my $i (0...$#$ready) { $load_avg = (59/60) * $load_avg + (1/60) * $ready->[$i]; push (@load_avg, $load_avg); if (defined $recent_delta->[$i]) { my ($twice_load) = $load_avg * 2; my ($load_factor) = $twice_load / ($twice_load + 1); $recent_cpu = ($recent_cpu + $recent_delta->[$i]) * $load_factor; push (@recent_cpu, $recent_cpu); } } return (\@load_avg, \@recent_cpu); } sub mlfqs_expected_ticks { my (@nice) = @_; my ($thread_cnt) = scalar (@nice); my (@recent_cpu) = (0) x $thread_cnt; my (@slices) = (0) x $thread_cnt; my (@fifo) = (0) x $thread_cnt; my ($next_fifo) = 1; my ($load_avg) = 0; for my $i (1...750) { if ($i % 25 == 0) { # Update load average. $load_avg = (59/60) * $load_avg + (1/60) * $thread_cnt; # Update recent_cpu. my ($twice_load) = $load_avg * 2; my ($load_factor) = $twice_load / ($twice_load + 1); $recent_cpu[$_] = $recent_cpu[$_] * $load_factor + $nice[$_] foreach 0...($thread_cnt - 1); } # Update priorities. my (@priority); foreach my $j (0...($thread_cnt - 1)) { my ($priority) = int ($recent_cpu[$j] / 4 + $nice[$j] * 2); $priority = 0 if $priority < 0; $priority = 63 if $priority > 63; push (@priority, $priority); } # Choose thread to run. my $max = 0; for my $j (1...$#priority) { if ($priority[$j] < $priority[$max] || ($priority[$j] == $priority[$max] && $fifo[$j] < $fifo[$max])) { $max = $j; } } $fifo[$max] = $next_fifo++; # Run thread. $recent_cpu[$max] += 4; $slices[$max] += 4; } return @slices; } sub check_mlfqs_fair { my ($nice, $maxdiff) = @_; our ($test); my (@output) = read_text_file ("$test.output"); common_checks ("run", @output); @output = get_core_output ("run", @output); my (@actual); local ($_); foreach (@output) { my ($id, $count) = /Thread (\d+) received (\d+) ticks\./ or next; $actual[$id] = $count; } my (@expected) = mlfqs_expected_ticks (@$nice); mlfqs_compare ("thread", "%d", \@actual, \@expected, $maxdiff, [0, $#$nice, 1], "Some tick counts were missing or differed from those " . "expected by more than $maxdiff."); pass; } sub mlfqs_compare { my ($indep_var, $format, $actual_ref, $expected_ref, $maxdiff, $t_range, $message) = @_; my ($t_min, $t_max, $t_step) = @$t_range; my ($ok) = 1; for (my ($t) = $t_min; $t <= $t_max; $t += $t_step) { my ($actual) = $actual_ref->[$t]; my ($expected) = $expected_ref->[$t]; $ok = 0, last if !defined ($actual) || abs ($actual - $expected) > $maxdiff + .01; } return if $ok; print "$message\n"; mlfqs_row ($indep_var, "actual", "<->", "expected", "explanation"); mlfqs_row ("------", "--------", "---", "--------", '-' x 40); for (my ($t) = $t_min; $t <= $t_max; $t += $t_step) { my ($actual) = $actual_ref->[$t]; my ($expected) = $expected_ref->[$t]; my ($diff, $rationale); if (!defined $actual) { $actual = 'undef' ; $diff = ''; $rationale = 'Missing value.'; } else { my ($delta) = abs ($actual - $expected); if ($delta > $maxdiff + .01) { my ($excess) = $delta - $maxdiff; if ($actual > $expected) { $diff = '>>>'; $rationale = sprintf "Too big, by $format.", $excess; } else { $diff = '<<<'; $rationale = sprintf "Too small, by $format.", $excess; } } else { $diff = ' = '; $rationale = ''; } $actual = sprintf ($format, $actual); } $expected = sprintf ($format, $expected); mlfqs_row ($t, $actual, $diff, $expected, $rationale); } fail; } sub mlfqs_row { printf "%6s %8s %3s %-8s %s\n", @_; } 1;
10cm
trunk/10cm/pintos/src/tests/threads/mlfqs.pm
Perl
oos
3,921
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected ([<<'EOF']); (alarm-priority) begin (alarm-priority) Thread priority 30 woke up. (alarm-priority) Thread priority 29 woke up. (alarm-priority) Thread priority 28 woke up. (alarm-priority) Thread priority 27 woke up. (alarm-priority) Thread priority 26 woke up. (alarm-priority) Thread priority 25 woke up. (alarm-priority) Thread priority 24 woke up. (alarm-priority) Thread priority 23 woke up. (alarm-priority) Thread priority 22 woke up. (alarm-priority) Thread priority 21 woke up. (alarm-priority) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/threads/alarm-priority.ck
Perl
oos
591
#ifndef TESTS_THREADS_TESTS_H #define TESTS_THREADS_TESTS_H void run_test (const char *); typedef void test_func (void); extern test_func test_alarm_single; extern test_func test_alarm_multiple; extern test_func test_alarm_simultaneous; extern test_func test_alarm_priority; extern test_func test_alarm_zero; extern test_func test_alarm_negative; extern test_func test_priority_change; extern test_func test_priority_donate_one; extern test_func test_priority_donate_multiple; extern test_func test_priority_donate_multiple2; extern test_func test_priority_donate_sema; extern test_func test_priority_donate_nest; extern test_func test_priority_donate_lower; extern test_func test_priority_donate_chain; extern test_func test_priority_fifo; extern test_func test_priority_preempt; extern test_func test_priority_sema; extern test_func test_priority_condvar; extern test_func test_mlfqs_load_1; extern test_func test_mlfqs_load_60; extern test_func test_mlfqs_load_avg; extern test_func test_mlfqs_recent_1; extern test_func test_mlfqs_fair_2; extern test_func test_mlfqs_fair_20; extern test_func test_mlfqs_nice_2; extern test_func test_mlfqs_nice_10; extern test_func test_mlfqs_block; void msg (const char *, ...); void fail (const char *, ...); void pass (void); #endif /* tests/threads/tests.h */
10cm
trunk/10cm/pintos/src/tests/threads/tests.h
C
oos
1,308
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::threads::mlfqs; check_mlfqs_fair ([0, 5], 50);
10cm
trunk/10cm/pintos/src/tests/threads/mlfqs-nice-2.ck
Perl
oos
118
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected ([<<'EOF']); (priority-donate-multiple2) begin (priority-donate-multiple2) Main thread should have priority 34. Actual priority: 34. (priority-donate-multiple2) Main thread should have priority 36. Actual priority: 36. (priority-donate-multiple2) Main thread should have priority 36. Actual priority: 36. (priority-donate-multiple2) Thread b acquired lock b. (priority-donate-multiple2) Thread b finished. (priority-donate-multiple2) Thread a acquired lock a. (priority-donate-multiple2) Thread a finished. (priority-donate-multiple2) Thread c finished. (priority-donate-multiple2) Threads b, a, c should have just finished, in that order. (priority-donate-multiple2) Main thread should have priority 31. Actual priority: 31. (priority-donate-multiple2) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/threads/priority-donate-multiple2.ck
Perl
oos
846
/* Creates N threads, each of which sleeps a different, fixed duration, M times. Records the wake-up order and verifies that it is valid. */ #include <stdio.h> #include "tests/threads/tests.h" #include "threads/init.h" #include "threads/malloc.h" #include "threads/synch.h" #include "threads/thread.h" #include "devices/timer.h" static void test_sleep (int thread_cnt, int iterations); void test_alarm_single (void) { test_sleep (5, 1); } void test_alarm_multiple (void) { test_sleep (5, 7); } /* Information about the test. */ struct sleep_test { int64_t start; /* Current time at start of test. */ int iterations; /* Number of iterations per thread. */ /* Output. */ struct lock output_lock; /* Lock protecting output buffer. */ int *output_pos; /* Current position in output buffer. */ }; /* Information about an individual thread in the test. */ struct sleep_thread { struct sleep_test *test; /* Info shared between all threads. */ int id; /* Sleeper ID. */ int duration; /* Number of ticks to sleep. */ int iterations; /* Iterations counted so far. */ }; static void sleeper (void *); /* Runs THREAD_CNT threads thread sleep ITERATIONS times each. */ static void test_sleep (int thread_cnt, int iterations) { struct sleep_test test; struct sleep_thread *threads; int *output, *op; int product; int i; /* This test does not work with the MLFQS. */ ASSERT (!thread_mlfqs); msg ("Creating %d threads to sleep %d times each.", thread_cnt, iterations); msg ("Thread 0 sleeps 10 ticks each time,"); msg ("thread 1 sleeps 20 ticks each time, and so on."); msg ("If successful, product of iteration count and"); msg ("sleep duration will appear in nondescending order."); /* Allocate memory. */ threads = malloc (sizeof *threads * thread_cnt); output = malloc (sizeof *output * iterations * thread_cnt * 2); if (threads == NULL || output == NULL) PANIC ("couldn't allocate memory for test"); /* Initialize test. */ test.start = timer_ticks () + 100; test.iterations = iterations; lock_init (&test.output_lock); test.output_pos = output; /* Start threads. */ ASSERT (output != NULL); for (i = 0; i < thread_cnt; i++) { struct sleep_thread *t = threads + i; char name[16]; t->test = &test; t->id = i; t->duration = (i + 1) * 10; t->iterations = 0; snprintf (name, sizeof name, "thread %d", i); thread_create (name, PRI_DEFAULT, sleeper, t); } /* Wait long enough for all the threads to finish. */ timer_sleep (100 + thread_cnt * iterations * 10 + 100); /* Acquire the output lock in case some rogue thread is still running. */ lock_acquire (&test.output_lock); /* Print completion order. */ product = 0; for (op = output; op < test.output_pos; op++) { struct sleep_thread *t; int new_prod; ASSERT (*op >= 0 && *op < thread_cnt); t = threads + *op; new_prod = ++t->iterations * t->duration; msg ("thread %d: duration=%d, iteration=%d, product=%d", t->id, t->duration, t->iterations, new_prod); if (new_prod >= product) product = new_prod; else fail ("thread %d woke up out of order (%d > %d)!", t->id, product, new_prod); } /* Verify that we had the proper number of wakeups. */ for (i = 0; i < thread_cnt; i++) if (threads[i].iterations != iterations) fail ("thread %d woke up %d times instead of %d", i, threads[i].iterations, iterations); lock_release (&test.output_lock); free (output); free (threads); } /* Sleeper thread. */ static void sleeper (void *t_) { struct sleep_thread *t = t_; struct sleep_test *test = t->test; int i; for (i = 1; i <= test->iterations; i++) { int64_t sleep_until = test->start + i * t->duration; timer_sleep (sleep_until - timer_ticks ()); lock_acquire (&test->output_lock); *test->output_pos++ = t->id; lock_release (&test->output_lock); } }
10cm
trunk/10cm/pintos/src/tests/threads/alarm-wait.c
C
oos
4,177
#include "tests/filesys/seq-test.h" #include <random.h> #include <syscall.h> #include "tests/lib.h" void seq_test (const char *file_name, void *buf, size_t size, size_t initial_size, size_t (*block_size_func) (void), void (*check_func) (int fd, long ofs)) { size_t ofs; int fd; random_bytes (buf, size); CHECK (create (file_name, initial_size), "create \"%s\"", file_name); CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); ofs = 0; msg ("writing \"%s\"", file_name); while (ofs < size) { size_t block_size = block_size_func (); if (block_size > size - ofs) block_size = size - ofs; if (write (fd, buf + ofs, block_size) != (int) block_size) fail ("write %zu bytes at offset %zu in \"%s\" failed", block_size, ofs, file_name); ofs += block_size; if (check_func != NULL) check_func (fd, ofs); } msg ("close \"%s\"", file_name); close (fd); check_file (file_name, buf, size); }
10cm
trunk/10cm/pintos/src/tests/filesys/seq-test.c
C
oos
1,017
#ifndef TESTS_FILESYS_SEQ_TEST_H #define TESTS_FILESYS_SEQ_TEST_H #include <stddef.h> void seq_test (const char *file_name, void *buf, size_t size, size_t initial_size, size_t (*block_size_func) (void), void (*check_func) (int fd, long ofs)); #endif /* tests/filesys/seq-test.h */
10cm
trunk/10cm/pintos/src/tests/filesys/seq-test.h
C
oos
329
/* -*- c -*- */ #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" static char buf[TEST_SIZE]; void test_main (void) { const char *file_name = "blargle"; CHECK (create (file_name, TEST_SIZE), "create \"%s\"", file_name); check_file (file_name, buf, TEST_SIZE); }
10cm
trunk/10cm/pintos/src/tests/filesys/create.inc
C
oos
290
/* Creates 50 files in the root directory. */ #define FILE_CNT 50 #include "tests/filesys/extended/grow-dir.inc"
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-root-lg.c
C
oos
114
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-tree-persistence.ck
Perl
oos
85
/* Tries to remove a parent of the current directory. This must fail, because that directory is non-empty. */ #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" void test_main (void) { CHECK (mkdir ("a"), "mkdir \"a\""); CHECK (chdir ("a"), "chdir \"a\""); CHECK (mkdir ("b"), "mkdir \"b\""); CHECK (chdir ("b"), "chdir \"b\""); CHECK (!remove ("/a"), "remove \"/a\" (must fail)"); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-parent.c
C
oos
418
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_archive ({"testfile" => [random_bytes (2134)]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-file-size-persistence.ck
Perl
oos
139
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-over-file) begin (dir-over-file) mkdir "abc" (dir-over-file) create "abc" (must return false) (dir-over-file) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-over-file.ck
Perl
oos
240
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-empty-name) begin (dir-empty-name) mkdir "" (must return false) (dir-empty-name) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-empty-name.ck
Perl
oos
211
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"testfile" => ["\0" x 76543]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-sparse-persistence.ck
Perl
oos
113
/* Grows a file in chunks while subprocesses read the growing file. */ #include <random.h> #include <syscall.h> #include "tests/filesys/extended/syn-rw.h" #include "tests/lib.h" #include "tests/main.h" char buf[BUF_SIZE]; #define CHILD_CNT 4 void test_main (void) { pid_t children[CHILD_CNT]; size_t ofs; int fd; CHECK (create (file_name, 0), "create \"%s\"", file_name); CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); exec_children ("child-syn-rw", children, CHILD_CNT); random_bytes (buf, sizeof buf); quiet = true; for (ofs = 0; ofs < BUF_SIZE; ofs += CHUNK_SIZE) CHECK (write (fd, buf + ofs, CHUNK_SIZE) > 0, "write %d bytes at offset %zu in \"%s\"", (int) CHUNK_SIZE, ofs, file_name); quiet = false; wait_children (children, CHILD_CNT); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/syn-rw.c
C
oos
820
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"a" => ["\0" x 243]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-root-persistence.ck
Perl
oos
104
# -*- perl -*- use strict; use warnings; use tests::tests; my ($cwd_removable) = read_text_file ("tests/filesys/extended/can-rmdir-cwd"); $cwd_removable eq 'YES' || $cwd_removable eq 'NO' or die; check_archive ($cwd_removable eq 'YES' ? {} : {"a" => {}}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-cwd-persistence.ck
Perl
oos
262
/* tar.c Creates a tar archive. */ #include <ustar.h> #include <syscall.h> #include <stdio.h> #include <string.h> static void usage (void); static bool make_tar_archive (const char *archive_name, char *files[], size_t file_cnt); int main (int argc, char *argv[]) { if (argc < 3) usage (); return (make_tar_archive (argv[1], argv + 2, argc - 2) ? EXIT_SUCCESS : EXIT_FAILURE); } static void usage (void) { printf ("tar, tar archive creator\n" "Usage: tar ARCHIVE FILE...\n" "where ARCHIVE is the tar archive to create\n" " and FILE... is a list of files or directories to put into it.\n" "(ARCHIVE itself will not be included in the archive, even if it\n" "is in a directory to be archived.)\n"); exit (EXIT_FAILURE); } static bool archive_file (char file_name[], size_t file_name_size, int archive_fd, bool *write_error); static bool archive_ordinary_file (const char *file_name, int file_fd, int archive_fd, bool *write_error); static bool archive_directory (char file_name[], size_t file_name_size, int file_fd, int archive_fd, bool *write_error); static bool write_header (const char *file_name, enum ustar_type, int size, int archive_fd, bool *write_error); static bool do_write (int fd, const char *buffer, int size, bool *write_error); static bool make_tar_archive (const char *archive_name, char *files[], size_t file_cnt) { static const char zeros[512]; int archive_fd; bool success = true; bool write_error = false; size_t i; if (!create (archive_name, 0)) { printf ("%s: create failed\n", archive_name); return false; } archive_fd = open (archive_name); if (archive_fd < 0) { printf ("%s: open failed\n", archive_name); return false; } for (i = 0; i < file_cnt; i++) { char file_name[128]; strlcpy (file_name, files[i], sizeof file_name); if (!archive_file (file_name, sizeof file_name, archive_fd, &write_error)) success = false; } if (!do_write (archive_fd, zeros, 512, &write_error) || !do_write (archive_fd, zeros, 512, &write_error)) success = false; close (archive_fd); return success; } static bool archive_file (char file_name[], size_t file_name_size, int archive_fd, bool *write_error) { int file_fd = open (file_name); if (file_fd >= 0) { bool success; if (inumber (file_fd) != inumber (archive_fd)) { if (!isdir (file_fd)) success = archive_ordinary_file (file_name, file_fd, archive_fd, write_error); else success = archive_directory (file_name, file_name_size, file_fd, archive_fd, write_error); } else { /* Nothing to do: don't try to archive the archive file. */ success = true; } close (file_fd); return success; } else { printf ("%s: open failed\n", file_name); return false; } } static bool archive_ordinary_file (const char *file_name, int file_fd, int archive_fd, bool *write_error) { bool read_error = false; bool success = true; int file_size = filesize (file_fd); if (!write_header (file_name, USTAR_REGULAR, file_size, archive_fd, write_error)) return false; while (file_size > 0) { static char buf[512]; int chunk_size = file_size > 512 ? 512 : file_size; int read_retval = read (file_fd, buf, chunk_size); int bytes_read = read_retval > 0 ? read_retval : 0; if (bytes_read != chunk_size && !read_error) { printf ("%s: read error\n", file_name); read_error = true; success = false; } memset (buf + bytes_read, 0, 512 - bytes_read); if (!do_write (archive_fd, buf, 512, write_error)) success = false; file_size -= chunk_size; } return success; } static bool archive_directory (char file_name[], size_t file_name_size, int file_fd, int archive_fd, bool *write_error) { size_t dir_len; bool success = true; dir_len = strlen (file_name); if (dir_len + 1 + READDIR_MAX_LEN + 1 > file_name_size) { printf ("%s: file name too long\n", file_name); return false; } if (!write_header (file_name, USTAR_DIRECTORY, 0, archive_fd, write_error)) return false; file_name[dir_len] = '/'; while (readdir (file_fd, &file_name[dir_len + 1])) if (!archive_file (file_name, file_name_size, archive_fd, write_error)) success = false; file_name[dir_len] = '\0'; return success; } static bool write_header (const char *file_name, enum ustar_type type, int size, int archive_fd, bool *write_error) { static char header[512]; return (ustar_make_header (file_name, type, size, header) && do_write (archive_fd, header, 512, write_error)); } static bool do_write (int fd, const char *buffer, int size, bool *write_error) { if (write (fd, buffer, size) == size) return true; else { if (!*write_error) { printf ("error writing archive\n"); *write_error = true; } return false; } }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/tar.c
C
oos
5,512
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-rm-tree) begin (dir-rm-tree) creating /0/0/0/0 through /3/2/2/3... (dir-rm-tree) open "/0/2/0/3" (dir-rm-tree) close "/0/2/0/3" (dir-rm-tree) removing /0/0/0/0 through /3/2/2/3... (dir-rm-tree) open "/3/0/2/0" (must return -1) (dir-rm-tree) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-tree.ck
Perl
oos
371
#ifndef TESTS_FILESYS_EXTENDED_SYN_RW_H #define TESTS_FILESYS_EXTENDED_SYN_RW_H #define CHUNK_SIZE 8 #define CHUNK_CNT 512 #define BUF_SIZE (CHUNK_SIZE * CHUNK_CNT) static const char file_name[] = "logfile"; #endif /* tests/filesys/extended/syn-rw.h */
10cm
trunk/10cm/pintos/src/tests/filesys/extended/syn-rw.h
C
oos
255
/* Grows two files in parallel and checks that their contents are correct. */ #include <random.h> #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" #define FILE_SIZE 8143 static char buf_a[FILE_SIZE]; static char buf_b[FILE_SIZE]; static void write_some_bytes (const char *file_name, int fd, const char *buf, size_t *ofs) { if (*ofs < FILE_SIZE) { size_t block_size = random_ulong () % (FILE_SIZE / 8) + 1; size_t ret_val; if (block_size > FILE_SIZE - *ofs) block_size = FILE_SIZE - *ofs; ret_val = write (fd, buf + *ofs, block_size); if (ret_val != block_size) fail ("write %zu bytes at offset %zu in \"%s\" returned %zu", block_size, *ofs, file_name, ret_val); *ofs += block_size; } } void test_main (void) { int fd_a, fd_b; size_t ofs_a = 0, ofs_b = 0; random_init (0); random_bytes (buf_a, sizeof buf_a); random_bytes (buf_b, sizeof buf_b); CHECK (create ("a", 0), "create \"a\""); CHECK (create ("b", 0), "create \"b\""); CHECK ((fd_a = open ("a")) > 1, "open \"a\""); CHECK ((fd_b = open ("b")) > 1, "open \"b\""); msg ("write \"a\" and \"b\" alternately"); while (ofs_a < FILE_SIZE || ofs_b < FILE_SIZE) { write_some_bytes ("a", fd_a, buf_a, &ofs_a); write_some_bytes ("b", fd_b, buf_b, &ofs_b); } msg ("close \"a\""); close (fd_a); msg ("close \"b\""); close (fd_b); check_file ("a", buf_a, FILE_SIZE); check_file ("b", buf_b, FILE_SIZE); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-two-files.c
C
oos
1,516
# -*- perl -*- use strict; use warnings; use tests::tests; my ($tree); for my $a (0...3) { for my $b (0...2) { for my $c (0...2) { for my $d (0...3) { $tree->{$a}{$b}{$c}{$d} = ['']; } } } } check_archive ($tree); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-mk-tree-persistence.ck
Perl
oos
242
/* Tries to create a directory with the same name as an existing file, which must return failure. */ #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" void test_main (void) { CHECK (create ("abc", 0), "create \"abc\""); CHECK (!mkdir ("abc"), "mkdir \"abc\" (must return false)"); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-under-file.c
C
oos
311
# -*- perl -*- use strict; use warnings; use tests::tests; my ($cwd_removable) = check_expected (IGNORE_EXIT_CODES => 1, {NO => <<'EOF', YES => <<'EOF'}); (dir-rm-cwd) begin (dir-rm-cwd) open "/" (dir-rm-cwd) mkdir "a" (dir-rm-cwd) open "/a" (dir-rm-cwd) verify "/a" is empty (dir-rm-cwd) "/" and "/a" must have different inumbers (dir-rm-cwd) chdir "a" (dir-rm-cwd) try to remove "/a" (dir-rm-cwd) remove failed (dir-rm-cwd) try to remove "../a" (must fail) (dir-rm-cwd) try to remove ".././a" (must fail) (dir-rm-cwd) try to remove "/./a" (must fail) (dir-rm-cwd) open "/a" (dir-rm-cwd) open "." (dir-rm-cwd) "/a" and "." must have same inumber (dir-rm-cwd) "/" and "/a" must have different inumbers (dir-rm-cwd) chdir "/a" (dir-rm-cwd) open "." (dir-rm-cwd) "." must have same inumber as before (dir-rm-cwd) chdir "/" (dir-rm-cwd) try to remove "a" (must fail: still open) (dir-rm-cwd) verify "/a" is empty (dir-rm-cwd) end EOF (dir-rm-cwd) begin (dir-rm-cwd) open "/" (dir-rm-cwd) mkdir "a" (dir-rm-cwd) open "/a" (dir-rm-cwd) verify "/a" is empty (dir-rm-cwd) "/" and "/a" must have different inumbers (dir-rm-cwd) chdir "a" (dir-rm-cwd) try to remove "/a" (dir-rm-cwd) remove successful (dir-rm-cwd) open "/a" (must fail) (dir-rm-cwd) open "." (must fail) (dir-rm-cwd) open ".." (must fail) (dir-rm-cwd) create "x" (must fail) (dir-rm-cwd) verify "/a" is empty (dir-rm-cwd) end EOF open (CAN_RMDIR_CWD, ">tests/filesys/extended/can-rmdir-cwd") or die "tests/filesys/extended/can-rmdir-cwd: create: $!\n"; print CAN_RMDIR_CWD "$cwd_removable"; close (CAN_RMDIR_CWD); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-cwd.ck
Perl
oos
1,590
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-root-lg) begin (grow-root-lg) creating and checking "file0" (grow-root-lg) creating and checking "file1" (grow-root-lg) creating and checking "file2" (grow-root-lg) creating and checking "file3" (grow-root-lg) creating and checking "file4" (grow-root-lg) creating and checking "file5" (grow-root-lg) creating and checking "file6" (grow-root-lg) creating and checking "file7" (grow-root-lg) creating and checking "file8" (grow-root-lg) creating and checking "file9" (grow-root-lg) creating and checking "file10" (grow-root-lg) creating and checking "file11" (grow-root-lg) creating and checking "file12" (grow-root-lg) creating and checking "file13" (grow-root-lg) creating and checking "file14" (grow-root-lg) creating and checking "file15" (grow-root-lg) creating and checking "file16" (grow-root-lg) creating and checking "file17" (grow-root-lg) creating and checking "file18" (grow-root-lg) creating and checking "file19" (grow-root-lg) creating and checking "file20" (grow-root-lg) creating and checking "file21" (grow-root-lg) creating and checking "file22" (grow-root-lg) creating and checking "file23" (grow-root-lg) creating and checking "file24" (grow-root-lg) creating and checking "file25" (grow-root-lg) creating and checking "file26" (grow-root-lg) creating and checking "file27" (grow-root-lg) creating and checking "file28" (grow-root-lg) creating and checking "file29" (grow-root-lg) creating and checking "file30" (grow-root-lg) creating and checking "file31" (grow-root-lg) creating and checking "file32" (grow-root-lg) creating and checking "file33" (grow-root-lg) creating and checking "file34" (grow-root-lg) creating and checking "file35" (grow-root-lg) creating and checking "file36" (grow-root-lg) creating and checking "file37" (grow-root-lg) creating and checking "file38" (grow-root-lg) creating and checking "file39" (grow-root-lg) creating and checking "file40" (grow-root-lg) creating and checking "file41" (grow-root-lg) creating and checking "file42" (grow-root-lg) creating and checking "file43" (grow-root-lg) creating and checking "file44" (grow-root-lg) creating and checking "file45" (grow-root-lg) creating and checking "file46" (grow-root-lg) creating and checking "file47" (grow-root-lg) creating and checking "file48" (grow-root-lg) creating and checking "file49" (grow-root-lg) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-root-lg.ck
Perl
oos
2,470
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-dir-lg) begin (grow-dir-lg) mkdir /x (grow-dir-lg) creating and checking "/x/file0" (grow-dir-lg) creating and checking "/x/file1" (grow-dir-lg) creating and checking "/x/file2" (grow-dir-lg) creating and checking "/x/file3" (grow-dir-lg) creating and checking "/x/file4" (grow-dir-lg) creating and checking "/x/file5" (grow-dir-lg) creating and checking "/x/file6" (grow-dir-lg) creating and checking "/x/file7" (grow-dir-lg) creating and checking "/x/file8" (grow-dir-lg) creating and checking "/x/file9" (grow-dir-lg) creating and checking "/x/file10" (grow-dir-lg) creating and checking "/x/file11" (grow-dir-lg) creating and checking "/x/file12" (grow-dir-lg) creating and checking "/x/file13" (grow-dir-lg) creating and checking "/x/file14" (grow-dir-lg) creating and checking "/x/file15" (grow-dir-lg) creating and checking "/x/file16" (grow-dir-lg) creating and checking "/x/file17" (grow-dir-lg) creating and checking "/x/file18" (grow-dir-lg) creating and checking "/x/file19" (grow-dir-lg) creating and checking "/x/file20" (grow-dir-lg) creating and checking "/x/file21" (grow-dir-lg) creating and checking "/x/file22" (grow-dir-lg) creating and checking "/x/file23" (grow-dir-lg) creating and checking "/x/file24" (grow-dir-lg) creating and checking "/x/file25" (grow-dir-lg) creating and checking "/x/file26" (grow-dir-lg) creating and checking "/x/file27" (grow-dir-lg) creating and checking "/x/file28" (grow-dir-lg) creating and checking "/x/file29" (grow-dir-lg) creating and checking "/x/file30" (grow-dir-lg) creating and checking "/x/file31" (grow-dir-lg) creating and checking "/x/file32" (grow-dir-lg) creating and checking "/x/file33" (grow-dir-lg) creating and checking "/x/file34" (grow-dir-lg) creating and checking "/x/file35" (grow-dir-lg) creating and checking "/x/file36" (grow-dir-lg) creating and checking "/x/file37" (grow-dir-lg) creating and checking "/x/file38" (grow-dir-lg) creating and checking "/x/file39" (grow-dir-lg) creating and checking "/x/file40" (grow-dir-lg) creating and checking "/x/file41" (grow-dir-lg) creating and checking "/x/file42" (grow-dir-lg) creating and checking "/x/file43" (grow-dir-lg) creating and checking "/x/file44" (grow-dir-lg) creating and checking "/x/file45" (grow-dir-lg) creating and checking "/x/file46" (grow-dir-lg) creating and checking "/x/file47" (grow-dir-lg) creating and checking "/x/file48" (grow-dir-lg) creating and checking "/x/file49" (grow-dir-lg) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-dir-lg.ck
Perl
oos
2,591
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-seq-sm) begin (grow-seq-sm) create "testme" (grow-seq-sm) open "testme" (grow-seq-sm) writing "testme" (grow-seq-sm) close "testme" (grow-seq-sm) open "testme" for verification (grow-seq-sm) verified contents of "testme" (grow-seq-sm) close "testme" (grow-seq-sm) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-seq-sm.ck
Perl
oos
414
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"blargle" => ['']}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-create-persistence.ck
Perl
oos
102
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_archive ({"foobar" => [random_bytes (2134)]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-tell-persistence.ck
Perl
oos
137
/* Creates 20 files in the root directory. */ #define FILE_CNT 20 #include "tests/filesys/extended/grow-dir.inc"
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-root-sm.c
C
oos
114
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-under-file) begin (dir-under-file) create "abc" (dir-under-file) mkdir "abc" (must return false) (dir-under-file) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-under-file.ck
Perl
oos
244
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; my ($fs); $fs->{'x'}{"file$_"} = [random_bytes (512)] foreach 0...49; check_archive ($fs); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-dir-lg-persistence.ck
Perl
oos
175
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"abc" => ['']}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-under-file-persistence.ck
Perl
oos
98
# -*- perl -*- use strict; use warnings; use tests::tests; # The archive should look like this: # # 40642 dir-vine # 42479 tar # 0 start # 11 start/file0 # 0 start/dir0 # 11 start/dir0/file1 # 0 start/dir0/dir1 # 11 start/dir0/dir1/file2 # 0 start/dir0/dir1/dir2 # 11 start/dir0/dir1/dir2/file3 # 0 start/dir0/dir1/dir2/dir3 # 11 start/dir0/dir1/dir2/dir3/file4 # 0 start/dir0/dir1/dir2/dir3/dir4 # 11 start/dir0/dir1/dir2/dir3/dir4/file5 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/file6 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/file7 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file8 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file9 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9 my ($dir) = {}; my ($root) = {"start" => $dir}; for (my ($i) = 0; $i < 10; $i++) { $dir->{"file$i"} = ["contents $i\n"]; $dir = $dir->{"dir$i"} = {}; } check_archive ($root); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-vine-persistence.ck
Perl
oos
1,170
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-mk-tree) begin (dir-mk-tree) creating /0/0/0/0 through /3/2/2/3... (dir-mk-tree) open "/0/2/0/3" (dir-mk-tree) close "/0/2/0/3" (dir-mk-tree) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-mk-tree.ck
Perl
oos
272
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"xyzzy" => {}}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-open-persistence.ck
Perl
oos
98
/* Creates directories /0/0/0 through /3/2/2 and creates files in the leaf directories. */ #include "tests/filesys/extended/mk-tree.h" #include "tests/main.h" void test_main (void) { make_tree (4, 3, 3, 4); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-mk-tree.c
C
oos
218
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-rm-parent) begin (dir-rm-parent) mkdir "a" (dir-rm-parent) chdir "a" (dir-rm-parent) mkdir "b" (dir-rm-parent) chdir "b" (dir-rm-parent) remove "/a" (must fail) (dir-rm-parent) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-parent.ck
Perl
oos
307
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-vine) begin (dir-vine) creating many levels of files and directories... (dir-vine) removing all but top 10 levels of files and directories... (dir-vine) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-vine.ck
Perl
oos
283
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"abc" => {}}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-over-file-persistence.ck
Perl
oos
96
/* Tests that seeking past the end of a file and writing will properly zero out the region in between. */ #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" static char buf[76543]; void test_main (void) { const char *file_name = "testfile"; char zero = 0; int fd; CHECK (create (file_name, 0), "create \"%s\"", file_name); CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); msg ("seek \"%s\"", file_name); seek (fd, sizeof buf - 1); CHECK (write (fd, &zero, 1) > 0, "write \"%s\"", file_name); msg ("close \"%s\"", file_name); close (fd); check_file (file_name, buf, sizeof buf); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-sparse.c
C
oos
643
/* Create a very deep "vine" of directories: /dir0/dir1/dir2/... and an ordinary file in each of them, until we fill up the disk. Then delete most of them, for two reasons. First, "tar" limits file names to 100 characters (which could be extended to 256 without much trouble). Second, a full disk has no room for the tar archive. */ #include <string.h> #include <stdio.h> #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" void test_main (void) { int i; msg ("creating many levels of files and directories..."); quiet = true; CHECK (mkdir ("start"), "mkdir \"start\""); CHECK (chdir ("start"), "chdir \"start\""); for (i = 0; ; i++) { char name[3][READDIR_MAX_LEN + 1]; char file_name[16], dir_name[16]; char contents[128]; int fd; /* Create file. */ snprintf (file_name, sizeof file_name, "file%d", i); if (!create (file_name, 0)) break; CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); snprintf (contents, sizeof contents, "contents %d\n", i); if (write (fd, contents, strlen (contents)) != (int) strlen (contents)) { CHECK (remove (file_name), "remove \"%s\"", file_name); close (fd); break; } close (fd); /* Create directory. */ snprintf (dir_name, sizeof dir_name, "dir%d", i); if (!mkdir (dir_name)) { CHECK (remove (file_name), "remove \"%s\"", file_name); break; } /* Check for file and directory. */ CHECK ((fd = open (".")) > 1, "open \".\""); CHECK (readdir (fd, name[0]), "readdir \".\""); CHECK (readdir (fd, name[1]), "readdir \".\""); CHECK (!readdir (fd, name[2]), "readdir \".\" (should fail)"); CHECK ((!strcmp (name[0], dir_name) && !strcmp (name[1], file_name)) || (!strcmp (name[1], dir_name) && !strcmp (name[0], file_name)), "names should be \"%s\" and \"%s\", " "actually \"%s\" and \"%s\"", file_name, dir_name, name[0], name[1]); close (fd); /* Descend into directory. */ CHECK (chdir (dir_name), "chdir \"%s\"", dir_name); } CHECK (i > 200, "created files and directories only to level %d", i); quiet = false; msg ("removing all but top 10 levels of files and directories..."); quiet = true; while (i-- > 10) { char file_name[16], dir_name[16]; snprintf (file_name, sizeof file_name, "file%d", i); snprintf (dir_name, sizeof dir_name, "dir%d", i); CHECK (chdir (".."), "chdir \"..\""); CHECK (remove (dir_name), "remove \"%s\"", dir_name); CHECK (remove (file_name), "remove \"%s\"", file_name); } quiet = false; }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-vine.c
C
oos
2,774
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; my ($a) = random_bytes (8143); my ($b) = random_bytes (8143); check_archive ({"a" => [$a], "b" => [$b]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-two-files-persistence.ck
Perl
oos
190
#ifndef TESTS_FILESYS_EXTENDED_MK_TREE_H #define TESTS_FILESYS_EXTENDED_MK_TREE_H void make_tree (int at, int bt, int ct, int dt); #endif /* tests/filesys/extended/mk-tree.h */
10cm
trunk/10cm/pintos/src/tests/filesys/extended/mk-tree.h
C
oos
179
/* Grows a file from 0 bytes to 72,943 bytes, 1,234 bytes at a time. */ #define TEST_SIZE 72943 #include "tests/filesys/extended/grow-seq.inc"
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-seq-lg.c
C
oos
147
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rmdir-persistence.ck
Perl
oos
85
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-two-files) begin (grow-two-files) create "a" (grow-two-files) create "b" (grow-two-files) open "a" (grow-two-files) open "b" (grow-two-files) write "a" and "b" alternately (grow-two-files) close "a" (grow-two-files) close "b" (grow-two-files) open "a" for verification (grow-two-files) verified contents of "a" (grow-two-files) close "a" (grow-two-files) open "b" for verification (grow-two-files) verified contents of "b" (grow-two-files) close "b" (grow-two-files) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-two-files.ck
Perl
oos
617
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-root-sm) begin (grow-root-sm) creating and checking "file0" (grow-root-sm) creating and checking "file1" (grow-root-sm) creating and checking "file2" (grow-root-sm) creating and checking "file3" (grow-root-sm) creating and checking "file4" (grow-root-sm) creating and checking "file5" (grow-root-sm) creating and checking "file6" (grow-root-sm) creating and checking "file7" (grow-root-sm) creating and checking "file8" (grow-root-sm) creating and checking "file9" (grow-root-sm) creating and checking "file10" (grow-root-sm) creating and checking "file11" (grow-root-sm) creating and checking "file12" (grow-root-sm) creating and checking "file13" (grow-root-sm) creating and checking "file14" (grow-root-sm) creating and checking "file15" (grow-root-sm) creating and checking "file16" (grow-root-sm) creating and checking "file17" (grow-root-sm) creating and checking "file18" (grow-root-sm) creating and checking "file19" (grow-root-sm) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-root-sm.ck
Perl
oos
1,090
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-create) begin (grow-create) create "blargle" (grow-create) open "blargle" for verification (grow-create) verified contents of "blargle" (grow-create) close "blargle" (grow-create) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-create.ck
Perl
oos
311
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-seq-lg) begin (grow-seq-lg) create "testme" (grow-seq-lg) open "testme" (grow-seq-lg) writing "testme" (grow-seq-lg) close "testme" (grow-seq-lg) open "testme" for verification (grow-seq-lg) verified contents of "testme" (grow-seq-lg) close "testme" (grow-seq-lg) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-seq-lg.ck
Perl
oos
414
/* Create a file of size 0. */ #define TEST_SIZE 0 #include "tests/filesys/create.inc"
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-create.c
C
oos
88
/* Creates a directory, then creates 50 files in that directory. */ #define FILE_CNT 50 #define DIRECTORY "/x" #include "tests/filesys/extended/grow-dir.inc"
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-dir-lg.c
C
oos
162
/* Tries to remove the current directory, which may succeed or fail. The requirements in each case are different; refer to the assignment for details. */ #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" static int wrap_open (const char *name) { static int fds[8], fd_cnt; int fd, i; CHECK ((fd = open (name)) > 1, "open \"%s\"", name); for (i = 0; i < fd_cnt; i++) if (fds[i] == fd) fail ("fd returned is not unique"); fds[fd_cnt++] = fd; return fd; } void test_main (void) { int root_fd, a_fd0; char name[READDIR_MAX_LEN + 1]; root_fd = wrap_open ("/"); CHECK (mkdir ("a"), "mkdir \"a\""); a_fd0 = wrap_open ("/a"); CHECK (!readdir (a_fd0, name), "verify \"/a\" is empty"); CHECK (inumber (root_fd) != inumber (a_fd0), "\"/\" and \"/a\" must have different inumbers"); CHECK (chdir ("a"), "chdir \"a\""); msg ("try to remove \"/a\""); if (remove ("/a")) { msg ("remove successful"); CHECK (open ("/a") == -1, "open \"/a\" (must fail)"); CHECK (open (".") == -1, "open \".\" (must fail)"); CHECK (open ("..") == -1, "open \"..\" (must fail)"); CHECK (!create ("x", 512), "create \"x\" (must fail)"); } else { int a_fd1, a_fd2, a_fd3; msg ("remove failed"); CHECK (!remove ("../a"), "try to remove \"../a\" (must fail)"); CHECK (!remove (".././a"), "try to remove \".././a\" (must fail)"); CHECK (!remove ("/./a"), "try to remove \"/./a\" (must fail)"); a_fd1 = wrap_open ("/a"); a_fd2 = wrap_open ("."); CHECK (inumber (a_fd1) == inumber (a_fd2), "\"/a\" and \".\" must have same inumber"); CHECK (inumber (root_fd) != inumber (a_fd1), "\"/\" and \"/a\" must have different inumbers"); CHECK (chdir ("/a"), "chdir \"/a\""); a_fd3 = wrap_open ("."); CHECK (inumber (a_fd3) == inumber (a_fd1), "\".\" must have same inumber as before"); CHECK (chdir ("/"), "chdir \"/\""); CHECK (!remove ("a"), "try to remove \"a\" (must fail: still open)"); } CHECK (!readdir (a_fd0, name), "verify \"/a\" is empty"); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-cwd.c
C
oos
2,169
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_archive ({"testme" => [random_bytes (72943)]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-seq-lg-persistence.ck
Perl
oos
138
/* Creates directories /0/0/0 through /3/2/2 and files in the leaf directories, then removes them. */ #include <stdarg.h> #include <stdio.h> #include <syscall.h> #include "tests/filesys/extended/mk-tree.h" #include "tests/lib.h" #include "tests/main.h" static void remove_tree (int at, int bt, int ct, int dt); void test_main (void) { make_tree (4, 3, 3, 4); remove_tree (4, 3, 3, 4); } static void do_remove (const char *format, ...) PRINTF_FORMAT (1, 2); static void remove_tree (int at, int bt, int ct, int dt) { char try[128]; int a, b, c, d; msg ("removing /0/0/0/0 through /%d/%d/%d/%d...", at - 1, bt - 1, ct - 1, dt - 1); quiet = true; for (a = 0; a < at; a++) { for (b = 0; b < bt; b++) { for (c = 0; c < ct; c++) { for (d = 0; d < dt; d++) do_remove ("/%d/%d/%d/%d", a, b, c, d); do_remove ("/%d/%d/%d", a, b, c); } do_remove ("/%d/%d", a, b); } do_remove ("/%d", a); } quiet = false; snprintf (try, sizeof (try), "/%d/%d/%d/%d", at - 1, 0, ct - 1, 0); CHECK (open (try) == -1, "open \"%s\" (must return -1)", try); } static void do_remove (const char *format, ...) { char name[128]; va_list args; va_start (args, format); vsnprintf (name, sizeof name, format, args); va_end (args); CHECK (remove (name), "remove \"%s\"", name); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-rm-tree.c
C
oos
1,423
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-mkdir) begin (dir-mkdir) mkdir "a" (dir-mkdir) create "a/b" (dir-mkdir) chdir "a" (dir-mkdir) open "b" (dir-mkdir) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-mkdir.ck
Perl
oos
245
/* Tries to create a directory named as the empty string, which must return failure. */ #include <syscall.h> #include "tests/lib.h" #include "tests/main.h" void test_main (void) { CHECK (!mkdir (""), "mkdir \"\" (must return false)"); }
10cm
trunk/10cm/pintos/src/tests/filesys/extended/dir-empty-name.c
C
oos
245
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-sparse) begin (grow-sparse) create "testfile" (grow-sparse) open "testfile" (grow-sparse) seek "testfile" (grow-sparse) write "testfile" (grow-sparse) close "testfile" (grow-sparse) open "testfile" for verification (grow-sparse) verified contents of "testfile" (grow-sparse) close "testfile" (grow-sparse) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/grow-sparse.ck
Perl
oos
437
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-vine) begin (dir-vine) creating many levels of files and directories... (dir-vine) removing all but top 10 levels of files and directories... (dir-vine) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-vine.ck.svn-base
Perl
oos
283
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-file-size) begin (grow-file-size) create "testfile" (grow-file-size) open "testfile" (grow-file-size) writing "testfile" (grow-file-size) close "testfile" (grow-file-size) open "testfile" for verification (grow-file-size) verified contents of "testfile" (grow-file-size) close "testfile" (grow-file-size) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-file-size.ck.svn-base
Perl
oos
455
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-rm-tree-persistence.ck.svn-base
Perl
oos
85
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-seq-lg) begin (grow-seq-lg) create "testme" (grow-seq-lg) open "testme" (grow-seq-lg) writing "testme" (grow-seq-lg) close "testme" (grow-seq-lg) open "testme" for verification (grow-seq-lg) verified contents of "testme" (grow-seq-lg) close "testme" (grow-seq-lg) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-seq-lg.ck.svn-base
Perl
oos
414
# -*- makefile -*- raw_tests = dir-empty-name dir-mk-tree dir-mkdir dir-open \ dir-over-file dir-rm-cwd dir-rm-parent dir-rm-root dir-rm-tree \ dir-rmdir dir-under-file dir-vine grow-create grow-dir-lg \ grow-file-size grow-root-lg grow-root-sm grow-seq-lg grow-seq-sm \ grow-sparse grow-tell grow-two-files syn-rw tests/filesys/extended_TESTS = $(patsubst %,tests/filesys/extended/%,$(raw_tests)) tests/filesys/extended_EXTRA_GRADES = $(patsubst %,tests/filesys/extended/%-persistence,$(raw_tests)) tests/filesys/extended_PROGS = $(tests/filesys/extended_TESTS) \ tests/filesys/extended/child-syn-rw tests/filesys/extended/tar $(foreach prog,$(tests/filesys/extended_PROGS), \ $(eval $(prog)_SRC += $(prog).c tests/lib.c tests/filesys/seq-test.c)) $(foreach prog,$(tests/filesys/extended_TESTS), \ $(eval $(prog)_SRC += tests/main.c)) $(foreach prog,$(tests/filesys/extended_TESTS), \ $(eval $(prog)_PUTFILES += tests/filesys/extended/tar)) # The version of GNU make 3.80 on vine barfs if this is split at # the last comma. $(foreach test,$(tests/filesys/extended_TESTS),$(eval $(test).output: FSDISK = tmp.dsk)) tests/filesys/extended/dir-mk-tree_SRC += tests/filesys/extended/mk-tree.c tests/filesys/extended/dir-rm-tree_SRC += tests/filesys/extended/mk-tree.c tests/filesys/extended/syn-rw_PUTFILES += tests/filesys/extended/child-syn-rw tests/filesys/extended/dir-vine.output: TIMEOUT = 150 GETTIMEOUT = 60 GETCMD = pintos -v -k -T $(GETTIMEOUT) GETCMD += $(PINTOSOPTS) GETCMD += $(SIMULATOR) GETCMD += --fs-disk=$(FSDISK) GETCMD += -g fs.tar -a $(TEST).tar ifeq ($(filter vm, $(KERNEL_SUBDIRS)), vm) GETCMD += --swap-disk=4 endif GETCMD += -- -q GETCMD += $(KERNELFLAGS) GETCMD += run 'tar fs.tar /' GETCMD += < /dev/null GETCMD += 2> $(TEST)-persistence.errors $(if $(VERBOSE),|tee,>) $(TEST)-persistence.output tests/filesys/extended/%.output: os.dsk rm -f tmp.dsk pintos-mkdisk tmp.dsk 2 $(TESTCMD) $(GETCMD) rm -f tmp.dsk $(foreach raw_test,$(raw_tests),$(eval tests/filesys/extended/$(raw_test)-persistence.output: tests/filesys/extended/$(raw_test).output)) $(foreach raw_test,$(raw_tests),$(eval tests/filesys/extended/$(raw_test)-persistence.result: tests/filesys/extended/$(raw_test).result)) TARS = $(addsuffix .tar,$(tests/filesys/extended_TESTS)) clean:: rm -f $(TARS) rm -f tests/filesys/extended/can-rmdir-cwd
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/Make.tests.svn-base
Makefile
oos
2,359
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({'a' => {'b' => ["\0" x 512]}}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-mkdir-persistence.ck.svn-base
Perl
oos
113
# -*- perl -*- use strict; use warnings; use tests::tests; my ($tree); for my $a (0...3) { for my $b (0...2) { for my $c (0...2) { for my $d (0...3) { $tree->{$a}{$b}{$c}{$d} = ['']; } } } } check_archive ($tree); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-mk-tree-persistence.ck.svn-base
Perl
oos
242
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; my ($fs); $fs->{'x'}{"file$_"} = [random_bytes (512)] foreach 0...49; check_archive ($fs); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-dir-lg-persistence.ck.svn-base
Perl
oos
175
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-rmdir) begin (dir-rmdir) mkdir "a" (dir-rmdir) rmdir "a" (dir-rmdir) chdir "a" (must return false) (dir-rmdir) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-rmdir.ck.svn-base
Perl
oos
241
# -*- perl -*- use strict; use warnings; use tests::tests; # The archive should look like this: # # 40642 dir-vine # 42479 tar # 0 start # 11 start/file0 # 0 start/dir0 # 11 start/dir0/file1 # 0 start/dir0/dir1 # 11 start/dir0/dir1/file2 # 0 start/dir0/dir1/dir2 # 11 start/dir0/dir1/dir2/file3 # 0 start/dir0/dir1/dir2/dir3 # 11 start/dir0/dir1/dir2/dir3/file4 # 0 start/dir0/dir1/dir2/dir3/dir4 # 11 start/dir0/dir1/dir2/dir3/dir4/file5 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/file6 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/file7 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file8 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8 # 11 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file9 # 0 start/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9 my ($dir) = {}; my ($root) = {"start" => $dir}; for (my ($i) = 0; $i < 10; $i++) { $dir->{"file$i"} = ["contents $i\n"]; $dir = $dir->{"dir$i"} = {}; } check_archive ($root); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-vine-persistence.ck.svn-base
Perl
oos
1,170
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_archive ({"testme" => [random_bytes (5678)]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-seq-sm-persistence.ck.svn-base
Perl
oos
137
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-seq-sm) begin (grow-seq-sm) create "testme" (grow-seq-sm) open "testme" (grow-seq-sm) writing "testme" (grow-seq-sm) close "testme" (grow-seq-sm) open "testme" for verification (grow-seq-sm) verified contents of "testme" (grow-seq-sm) close "testme" (grow-seq-sm) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-seq-sm.ck.svn-base
Perl
oos
414
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-empty-name-persistence.ck.svn-base
Perl
oos
85
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-over-file) begin (dir-over-file) mkdir "abc" (dir-over-file) create "abc" (must return false) (dir-over-file) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-over-file.ck.svn-base
Perl
oos
240
# -*- perl -*- use strict; use warnings; use tests::tests; my ($cwd_removable) = read_text_file ("tests/filesys/extended/can-rmdir-cwd"); $cwd_removable eq 'YES' || $cwd_removable eq 'NO' or die; check_archive ($cwd_removable eq 'YES' ? {} : {"a" => {}}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-rm-cwd-persistence.ck.svn-base
Perl
oos
262
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-empty-name) begin (dir-empty-name) mkdir "" (must return false) (dir-empty-name) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-empty-name.ck.svn-base
Perl
oos
211
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_archive ({"foobar" => [random_bytes (2134)]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-tell-persistence.ck.svn-base
Perl
oos
137
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-dir-lg) begin (grow-dir-lg) mkdir /x (grow-dir-lg) creating and checking "/x/file0" (grow-dir-lg) creating and checking "/x/file1" (grow-dir-lg) creating and checking "/x/file2" (grow-dir-lg) creating and checking "/x/file3" (grow-dir-lg) creating and checking "/x/file4" (grow-dir-lg) creating and checking "/x/file5" (grow-dir-lg) creating and checking "/x/file6" (grow-dir-lg) creating and checking "/x/file7" (grow-dir-lg) creating and checking "/x/file8" (grow-dir-lg) creating and checking "/x/file9" (grow-dir-lg) creating and checking "/x/file10" (grow-dir-lg) creating and checking "/x/file11" (grow-dir-lg) creating and checking "/x/file12" (grow-dir-lg) creating and checking "/x/file13" (grow-dir-lg) creating and checking "/x/file14" (grow-dir-lg) creating and checking "/x/file15" (grow-dir-lg) creating and checking "/x/file16" (grow-dir-lg) creating and checking "/x/file17" (grow-dir-lg) creating and checking "/x/file18" (grow-dir-lg) creating and checking "/x/file19" (grow-dir-lg) creating and checking "/x/file20" (grow-dir-lg) creating and checking "/x/file21" (grow-dir-lg) creating and checking "/x/file22" (grow-dir-lg) creating and checking "/x/file23" (grow-dir-lg) creating and checking "/x/file24" (grow-dir-lg) creating and checking "/x/file25" (grow-dir-lg) creating and checking "/x/file26" (grow-dir-lg) creating and checking "/x/file27" (grow-dir-lg) creating and checking "/x/file28" (grow-dir-lg) creating and checking "/x/file29" (grow-dir-lg) creating and checking "/x/file30" (grow-dir-lg) creating and checking "/x/file31" (grow-dir-lg) creating and checking "/x/file32" (grow-dir-lg) creating and checking "/x/file33" (grow-dir-lg) creating and checking "/x/file34" (grow-dir-lg) creating and checking "/x/file35" (grow-dir-lg) creating and checking "/x/file36" (grow-dir-lg) creating and checking "/x/file37" (grow-dir-lg) creating and checking "/x/file38" (grow-dir-lg) creating and checking "/x/file39" (grow-dir-lg) creating and checking "/x/file40" (grow-dir-lg) creating and checking "/x/file41" (grow-dir-lg) creating and checking "/x/file42" (grow-dir-lg) creating and checking "/x/file43" (grow-dir-lg) creating and checking "/x/file44" (grow-dir-lg) creating and checking "/x/file45" (grow-dir-lg) creating and checking "/x/file46" (grow-dir-lg) creating and checking "/x/file47" (grow-dir-lg) creating and checking "/x/file48" (grow-dir-lg) creating and checking "/x/file49" (grow-dir-lg) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-dir-lg.ck.svn-base
Perl
oos
2,591
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-rmdir-persistence.ck.svn-base
Perl
oos
85
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-root-lg) begin (grow-root-lg) creating and checking "file0" (grow-root-lg) creating and checking "file1" (grow-root-lg) creating and checking "file2" (grow-root-lg) creating and checking "file3" (grow-root-lg) creating and checking "file4" (grow-root-lg) creating and checking "file5" (grow-root-lg) creating and checking "file6" (grow-root-lg) creating and checking "file7" (grow-root-lg) creating and checking "file8" (grow-root-lg) creating and checking "file9" (grow-root-lg) creating and checking "file10" (grow-root-lg) creating and checking "file11" (grow-root-lg) creating and checking "file12" (grow-root-lg) creating and checking "file13" (grow-root-lg) creating and checking "file14" (grow-root-lg) creating and checking "file15" (grow-root-lg) creating and checking "file16" (grow-root-lg) creating and checking "file17" (grow-root-lg) creating and checking "file18" (grow-root-lg) creating and checking "file19" (grow-root-lg) creating and checking "file20" (grow-root-lg) creating and checking "file21" (grow-root-lg) creating and checking "file22" (grow-root-lg) creating and checking "file23" (grow-root-lg) creating and checking "file24" (grow-root-lg) creating and checking "file25" (grow-root-lg) creating and checking "file26" (grow-root-lg) creating and checking "file27" (grow-root-lg) creating and checking "file28" (grow-root-lg) creating and checking "file29" (grow-root-lg) creating and checking "file30" (grow-root-lg) creating and checking "file31" (grow-root-lg) creating and checking "file32" (grow-root-lg) creating and checking "file33" (grow-root-lg) creating and checking "file34" (grow-root-lg) creating and checking "file35" (grow-root-lg) creating and checking "file36" (grow-root-lg) creating and checking "file37" (grow-root-lg) creating and checking "file38" (grow-root-lg) creating and checking "file39" (grow-root-lg) creating and checking "file40" (grow-root-lg) creating and checking "file41" (grow-root-lg) creating and checking "file42" (grow-root-lg) creating and checking "file43" (grow-root-lg) creating and checking "file44" (grow-root-lg) creating and checking "file45" (grow-root-lg) creating and checking "file46" (grow-root-lg) creating and checking "file47" (grow-root-lg) creating and checking "file48" (grow-root-lg) creating and checking "file49" (grow-root-lg) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-root-lg.ck.svn-base
Perl
oos
2,470
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"testfile" => ["\0" x 76543]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-sparse-persistence.ck.svn-base
Perl
oos
113
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"abc" => ['']}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-under-file-persistence.ck.svn-base
Perl
oos
98
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; my ($a) = random_bytes (8143); my ($b) = random_bytes (8143); check_archive ({"a" => [$a], "b" => [$b]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-two-files-persistence.ck.svn-base
Perl
oos
190
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (dir-rm-parent) begin (dir-rm-parent) mkdir "a" (dir-rm-parent) chdir "a" (dir-rm-parent) mkdir "b" (dir-rm-parent) chdir "b" (dir-rm-parent) remove "/a" (must fail) (dir-rm-parent) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-rm-parent.ck.svn-base
Perl
oos
307
# -*- perl -*- use strict; use warnings; use tests::tests; check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); (grow-create) begin (grow-create) create "blargle" (grow-create) open "blargle" for verification (grow-create) verified contents of "blargle" (grow-create) close "blargle" (grow-create) end EOF pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-create.ck.svn-base
Perl
oos
311
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; my ($fs); $fs->{"file$_"} = [random_bytes (512)] foreach 0...19; check_archive ($fs); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-root-sm-persistence.ck.svn-base
Perl
oos
170
# -*- perl -*- use strict; use warnings; use tests::tests; use tests::random; check_archive ({"testfile" => [random_bytes (2134)]}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/grow-file-size-persistence.ck.svn-base
Perl
oos
139
# -*- perl -*- use strict; use warnings; use tests::tests; check_archive ({"a" => {"b" => {}}}); pass;
10cm
trunk/10cm/pintos/src/tests/filesys/extended/.svn/text-base/dir-rm-parent-persistence.ck.svn-base
Perl
oos
103