PKUOS - Pintos
Pintos source browser for PKU Operating System course
Typedefs | Functions | Variables
tests.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void test_func(void)
 

Functions

void run_test (const char *)
 Runs the test named NAME. More...
 
void msg (const char *,...)
 Prints FORMAT as if with printf(), prefixing the output by the name of the test and following it with a new-line character. More...
 
void fail (const char *,...)
 Prints failure message FORMAT as if with printf(), prefixing the output by the name of the test and FAIL: and following it with a new-line character, and then panics the kernel. More...
 
void pass (void)
 tests/threads/tests.h More...
 

Variables

test_func test_alarm_single
 
test_func test_alarm_multiple
 
test_func test_alarm_simultaneous
 
test_func test_alarm_priority
 
test_func test_alarm_zero
 Tests timer_sleep(0), which should return immediately. More...
 
test_func test_alarm_negative
 Tests timer_sleep(-100). More...
 
test_func test_priority_change
 
test_func test_priority_donate_one
 
test_func test_priority_donate_multiple
 
test_func test_priority_donate_multiple2
 
test_func test_priority_donate_sema
 
test_func test_priority_donate_nest
 
test_func test_priority_donate_lower
 
test_func test_priority_donate_chain
 
test_func test_priority_fifo
 
test_func test_priority_preempt
 
test_func test_priority_sema
 
test_func test_priority_condvar
 
test_func test_mlfqs_load_1
 Verifies that a single busy thread raises the load average to 0.5 in 38 to 45 seconds. More...
 
test_func test_mlfqs_load_60
 
test_func test_mlfqs_load_avg
 
test_func test_mlfqs_recent_1
 Checks that recent_cpu is calculated properly for the case of a single ready process. More...
 
test_func test_mlfqs_fair_2
 
test_func test_mlfqs_fair_20
 
test_func test_mlfqs_nice_2
 
test_func test_mlfqs_nice_10
 
test_func test_mlfqs_block
 

Typedef Documentation

◆ test_func

typedef void test_func(void)

Definition at line 6 of file tests.h.

Function Documentation

◆ fail()

void fail ( const char *  format,
  ... 
)

Prints failure message FORMAT as if with printf(), prefixing the output by the name of the test and FAIL: and following it with a new-line character, and then panics the kernel.

Definition at line 40 of file lib.c.

References exit(), PANIC, printf(), putchar(), test_name, va_end, va_start, vmsg(), and vprintf().

Referenced by check_file_handle(), check_file_size(), check_tell(), compare_bytes(), main(), seq_test(), test_main(), test_sleep(), verify(), wrap_open(), and write_some_bytes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msg()

void msg ( const char *  format,
  ... 
)

◆ pass()

void pass ( void  )

tests/threads/tests.h

tests/threads/tests.h

Definition at line 98 of file tests.c.

References printf(), and test_name.

Here is the call graph for this function:

◆ run_test()

void run_test ( const char *  name)

Runs the test named NAME.

Definition at line 47 of file tests.c.

References test::function, msg(), name, test::name, PANIC, strcmp(), test_name, and tests.

Referenced by run_task().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ test_alarm_multiple

test_func test_alarm_multiple ( void  )
extern

Definition at line 22 of file alarm-wait.c.

◆ test_alarm_negative

test_func test_alarm_negative ( void  )
extern

Tests timer_sleep(-100).

Only requirement is that it not crash.

Definition at line 11 of file alarm-negative.c.

◆ test_alarm_priority

test_func test_alarm_priority ( void  )
extern

Definition at line 17 of file alarm-priority.c.

◆ test_alarm_simultaneous

test_func test_alarm_simultaneous ( void  )
extern

Definition at line 16 of file alarm-simultaneous.c.

◆ test_alarm_single

test_func test_alarm_single ( void  )
extern

Definition at line 16 of file alarm-wait.c.

◆ test_alarm_zero

test_func test_alarm_zero ( void  )
extern

Tests timer_sleep(0), which should return immediately.

Definition at line 11 of file alarm-zero.c.

◆ test_mlfqs_block

test_func test_mlfqs_block ( void  )
extern

Definition at line 23 of file mlfqs-block.c.

◆ test_mlfqs_fair_2

test_func test_mlfqs_fair_2 ( void  )
extern

Definition at line 31 of file mlfqs-fair.c.

◆ test_mlfqs_fair_20

test_func test_mlfqs_fair_20 ( void  )
extern

Definition at line 37 of file mlfqs-fair.c.

◆ test_mlfqs_load_1

test_func test_mlfqs_load_1 ( void  )
extern

Verifies that a single busy thread raises the load average to 0.5 in 38 to 45 seconds.

The expected time is 42 seconds, as you can verify: perl -e '$i++,$a=(59*$a+1)/60while$a<=.5;print "$i\n"'

Then, verifies that 10 seconds of inactivity drop the load average back below 0.5 again.

Definition at line 18 of file mlfqs-load-1.c.

◆ test_mlfqs_load_60

test_func test_mlfqs_load_60 ( void  )
extern

Definition at line 115 of file mlfqs-load-60.c.

◆ test_mlfqs_load_avg

test_func test_mlfqs_load_avg ( void  )
extern

Definition at line 126 of file mlfqs-load-avg.c.

◆ test_mlfqs_nice_10

test_func test_mlfqs_nice_10 ( void  )
extern

Definition at line 49 of file mlfqs-fair.c.

◆ test_mlfqs_nice_2

test_func test_mlfqs_nice_2 ( void  )
extern

Definition at line 43 of file mlfqs-fair.c.

◆ test_mlfqs_recent_1

test_func test_mlfqs_recent_1 ( void  )
extern

Checks that recent_cpu is calculated properly for the case of a single ready process.

The expected output is this (some margin of error is allowed):

After 2 seconds, recent_cpu is 6.40, load_avg is 0.03. After 4 seconds, recent_cpu is 12.60, load_avg is 0.07. After 6 seconds, recent_cpu is 18.61, load_avg is 0.10. After 8 seconds, recent_cpu is 24.44, load_avg is 0.13. After 10 seconds, recent_cpu is 30.08, load_avg is 0.15. After 12 seconds, recent_cpu is 35.54, load_avg is 0.18. After 14 seconds, recent_cpu is 40.83, load_avg is 0.21. After 16 seconds, recent_cpu is 45.96, load_avg is 0.24. After 18 seconds, recent_cpu is 50.92, load_avg is 0.26. After 20 seconds, recent_cpu is 55.73, load_avg is 0.29. After 22 seconds, recent_cpu is 60.39, load_avg is 0.31. After 24 seconds, recent_cpu is 64.90, load_avg is 0.33. After 26 seconds, recent_cpu is 69.27, load_avg is 0.35. After 28 seconds, recent_cpu is 73.50, load_avg is 0.38. After 30 seconds, recent_cpu is 77.60, load_avg is 0.40. After 32 seconds, recent_cpu is 81.56, load_avg is 0.42. After 34 seconds, recent_cpu is 85.40, load_avg is 0.44. After 36 seconds, recent_cpu is 89.12, load_avg is 0.45. After 38 seconds, recent_cpu is 92.72, load_avg is 0.47. After 40 seconds, recent_cpu is 96.20, load_avg is 0.49. After 42 seconds, recent_cpu is 99.57, load_avg is 0.51. After 44 seconds, recent_cpu is 102.84, load_avg is 0.52. After 46 seconds, recent_cpu is 106.00, load_avg is 0.54. After 48 seconds, recent_cpu is 109.06, load_avg is 0.55. After 50 seconds, recent_cpu is 112.02, load_avg is 0.57. After 52 seconds, recent_cpu is 114.89, load_avg is 0.58. After 54 seconds, recent_cpu is 117.66, load_avg is 0.60. After 56 seconds, recent_cpu is 120.34, load_avg is 0.61. After 58 seconds, recent_cpu is 122.94, load_avg is 0.62. After 60 seconds, recent_cpu is 125.46, load_avg is 0.64. After 62 seconds, recent_cpu is 127.89, load_avg is 0.65. After 64 seconds, recent_cpu is 130.25, load_avg is 0.66. After 66 seconds, recent_cpu is 132.53, load_avg is 0.67. After 68 seconds, recent_cpu is 134.73, load_avg is 0.68. After 70 seconds, recent_cpu is 136.86, load_avg is 0.69. After 72 seconds, recent_cpu is 138.93, load_avg is 0.70. After 74 seconds, recent_cpu is 140.93, load_avg is 0.71. After 76 seconds, recent_cpu is 142.86, load_avg is 0.72. After 78 seconds, recent_cpu is 144.73, load_avg is 0.73. After 80 seconds, recent_cpu is 146.54, load_avg is 0.74. After 82 seconds, recent_cpu is 148.29, load_avg is 0.75. After 84 seconds, recent_cpu is 149.99, load_avg is 0.76. After 86 seconds, recent_cpu is 151.63, load_avg is 0.76. After 88 seconds, recent_cpu is 153.21, load_avg is 0.77. After 90 seconds, recent_cpu is 154.75, load_avg is 0.78. After 92 seconds, recent_cpu is 156.23, load_avg is 0.79. After 94 seconds, recent_cpu is 157.67, load_avg is 0.79. After 96 seconds, recent_cpu is 159.06, load_avg is 0.80. After 98 seconds, recent_cpu is 160.40, load_avg is 0.81. After 100 seconds, recent_cpu is 161.70, load_avg is 0.81. After 102 seconds, recent_cpu is 162.96, load_avg is 0.82. After 104 seconds, recent_cpu is 164.18, load_avg is 0.83. After 106 seconds, recent_cpu is 165.35, load_avg is 0.83. After 108 seconds, recent_cpu is 166.49, load_avg is 0.84. After 110 seconds, recent_cpu is 167.59, load_avg is 0.84. After 112 seconds, recent_cpu is 168.66, load_avg is 0.85. After 114 seconds, recent_cpu is 169.69, load_avg is 0.85. After 116 seconds, recent_cpu is 170.69, load_avg is 0.86. After 118 seconds, recent_cpu is 171.65, load_avg is 0.86. After 120 seconds, recent_cpu is 172.58, load_avg is 0.87. After 122 seconds, recent_cpu is 173.49, load_avg is 0.87. After 124 seconds, recent_cpu is 174.36, load_avg is 0.88. After 126 seconds, recent_cpu is 175.20, load_avg is 0.88. After 128 seconds, recent_cpu is 176.02, load_avg is 0.88. After 130 seconds, recent_cpu is 176.81, load_avg is 0.89. After 132 seconds, recent_cpu is 177.57, load_avg is 0.89. After 134 seconds, recent_cpu is 178.31, load_avg is 0.89. After 136 seconds, recent_cpu is 179.02, load_avg is 0.90. After 138 seconds, recent_cpu is 179.72, load_avg is 0.90. After 140 seconds, recent_cpu is 180.38, load_avg is 0.90. After 142 seconds, recent_cpu is 181.03, load_avg is 0.91. After 144 seconds, recent_cpu is 181.65, load_avg is 0.91. After 146 seconds, recent_cpu is 182.26, load_avg is 0.91. After 148 seconds, recent_cpu is 182.84, load_avg is 0.92. After 150 seconds, recent_cpu is 183.41, load_avg is 0.92. After 152 seconds, recent_cpu is 183.96, load_avg is 0.92. After 154 seconds, recent_cpu is 184.49, load_avg is 0.92. After 156 seconds, recent_cpu is 185.00, load_avg is 0.93. After 158 seconds, recent_cpu is 185.49, load_avg is 0.93. After 160 seconds, recent_cpu is 185.97, load_avg is 0.93. After 162 seconds, recent_cpu is 186.43, load_avg is 0.93. After 164 seconds, recent_cpu is 186.88, load_avg is 0.94. After 166 seconds, recent_cpu is 187.31, load_avg is 0.94. After 168 seconds, recent_cpu is 187.73, load_avg is 0.94. After 170 seconds, recent_cpu is 188.14, load_avg is 0.94. After 172 seconds, recent_cpu is 188.53, load_avg is 0.94. After 174 seconds, recent_cpu is 188.91, load_avg is 0.95. After 176 seconds, recent_cpu is 189.27, load_avg is 0.95. After 178 seconds, recent_cpu is 189.63, load_avg is 0.95. After 180 seconds, recent_cpu is 189.97, load_avg is 0.95. Sensitive to assumption that recent_cpu updates happen exactly when timer_ticks() % TIMER_FREQ == 0.

Definition at line 110 of file mlfqs-recent-1.c.

◆ test_priority_change

test_func test_priority_change ( void  )
extern

Definition at line 13 of file priority-change.c.

◆ test_priority_condvar

test_func test_priority_condvar ( void  )
extern

Definition at line 17 of file priority-condvar.c.

◆ test_priority_donate_chain

test_func test_priority_donate_chain ( void  )
extern

Definition at line 45 of file priority-donate-chain.c.

◆ test_priority_donate_lower

test_func test_priority_donate_lower ( void  )
extern

Definition at line 16 of file priority-donate-lower.c.

◆ test_priority_donate_multiple

test_func test_priority_donate_multiple ( void  )
extern

Definition at line 22 of file priority-donate-multiple.c.

◆ test_priority_donate_multiple2

test_func test_priority_donate_multiple2 ( void  )
extern

Definition at line 28 of file priority-donate-multiple2.c.

◆ test_priority_donate_nest

test_func test_priority_donate_nest ( void  )
extern

Definition at line 28 of file priority-donate-nest.c.

◆ test_priority_donate_one

test_func test_priority_donate_one ( void  )
extern

Definition at line 22 of file priority-donate-one.c.

◆ test_priority_donate_sema

test_func test_priority_donate_sema ( void  )
extern

Definition at line 30 of file priority-donate-sema.c.

◆ test_priority_fifo

test_func test_priority_fifo ( void  )
extern

Definition at line 32 of file priority-fifo.c.

◆ test_priority_preempt

test_func test_priority_preempt ( void  )
extern

Definition at line 18 of file priority-preempt.c.

◆ test_priority_sema

test_func test_priority_sema ( void  )
extern

Definition at line 16 of file priority-sema.c.