• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..16-Feb-2021-

README.nacl_file_lock_testH A D16-Feb-20213.2 KiB8262

nacl_clock.cH A D16-Feb-20215.3 KiB157122

nacl_host_dir.cH A D16-Feb-20215.8 KiB212160

nacl_host_dir_types.hH A D16-Feb-2021691 2712

nacl_semaphore.cH A D16-Feb-20214 KiB164115

nacl_semaphore.hH A D16-Feb-20211.1 KiB4419

README.nacl_file_lock_test

1NaCl File Lock Tests
2
3The nacl_file_lock_test test driver implements an interpreter for a
4test language to allow simple, easy to read test programs to drive
5tests.  The test language is based on Lisp, primarily because it's
6easy to parse.  (See nacl_sexp.[ch] for the parser.)
7
8File Locking Test Framework
9
10The test framework allows us to write tests that tell worker threads
11to perform actions and for the main thread to look for events that
12should occur as a result.  Architecturally, the worker threads accept
13work orders from the main thread and post events as the work is done,
14and the main thread sends work requests to the worker threads and uses
15"matcher" functions to recognize whether an expected set of events
16occurred.
17
18Event matching functions succeed and return information used by the
19(match ...) function, which ensures that all events that occurred are
20accounted for, i.e., no unexpected event occurred.  Event matchers can
21be composed with (all ...) and (any ...) functions.  In the former
22case, (all ...) is used when several events should occur as a result
23of an action, e.g., unlock succeeding and another thread immediately
24acquiring the lock; the order in which the events occur does not
25matter.  In the latter case, (any ...) is used when, for example,
26unlocking a file could result in one of several sets of events because
27there are multiple worker threads waiting for the lock and any of them
28might succeed.  The return value of all matchers is a list of two
29integers, with the index (0-based) of the matcher that succeeded as
30the first element, and the bitmask of the position in the event queue
31of the events "consumed" by the match as the second element.  The
32(match ...) function consumes the bitmask and returns the index.  It
33is only the (any ...) function where the index matters, since it is
34the only matcher that permits alternation.  The index is typically
35used with the (nth ...) function to pick the next step(s) to execute
36in the test.
37
38At the language level, we have these domain-specific functions:
39
40  ;;; Initialization
41
42  (set-threads <num-threads>)
43  (set-files <num-files>)
44
45  ;;; Commands
46
47  (lock <thread-num> <file-num>)   ;;; thread <thread-num> locks <file-num>
48  (unlock <thread-num> <file-num>) ;;; thread <thread-num> unlocks <file-num>
49
50  ;;; Wait for events to occur (with timeout).  If <matcher> matched
51  ;;; all events in the event set, remove events and succeed,
52  ;;; proceeding to the next function.  Otherwise the test fails.  If
53  ;;; the matcher is (any ...), the index of the successful matcher is
54  ;;; returned.
55  (match <matcher>)
56
57  ;;; Event Matchers
58
59  ;;; Matches the event <thread-num> locked <file-num>
60  (locked <thread-num> <file-num>)
61
62  ;;; Matches the event <thread-num> unlocked <file-num>
63  (unlocked <thread-num> <file-num>)
64
65  ;;; Matches when no event occurs (up to timeout)
66  (epsilon)
67
68  ;;; Matches if any of the matchers in the list match
69  (any <matcher1> <matcher2>...)
70
71  ;;; Matches if all matchers in the list match
72  (all <matcher1> <matcher2>...)
73
74
75Additionally, some basic, standard Lisp functions / special forms are
76included:
77
78  (quote <s-expression>)
79  (eval <s-expression>)
80  (nth <num> (<s-expression1> <s-expression2>...))
81  (progn <s-expression>...)
82