PKUOS - Pintos
Pintos source browser for PKU Operating System course
Data Structures | Functions | Variables
tests.c File Reference
#include "tests/threads/tests.h"
#include <debug.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for tests.c:

Go to the source code of this file.

Data Structures

struct  test
 

Functions

void run_test (const char *name)
 Runs the test named NAME. More...
 
void msg (const char *format,...)
 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 *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. More...
 
void pass (void)
 Prints a message indicating the current test passed. More...
 

Variables

static const struct test tests []
 
static const char * test_name
 

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 83 of file tests.c.

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

Here is the call graph for this function:

◆ msg()

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

Prints FORMAT as if with printf(), prefixing the output by the name of the test and following it with a new-line character.

Definition at line 67 of file tests.c.

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

Referenced by run_test().

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

◆ pass()

void pass ( void  )

Prints a message indicating the current test passed.

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_name

const char* test_name
static

Definition at line 43 of file tests.c.

Referenced by fail(), msg(), pass(), and run_test().

◆ tests

const struct test tests[]
static
Initial value:
=
{
{"alarm-single", test_alarm_single},
{"alarm-multiple", test_alarm_multiple},
{"alarm-simultaneous", test_alarm_simultaneous},
{"alarm-priority", test_alarm_priority},
{"alarm-zero", test_alarm_zero},
{"alarm-negative", test_alarm_negative},
{"priority-change", test_priority_change},
{"priority-donate-one", test_priority_donate_one},
{"priority-donate-multiple", test_priority_donate_multiple},
{"priority-donate-multiple2", test_priority_donate_multiple2},
{"priority-donate-nest", test_priority_donate_nest},
{"priority-donate-sema", test_priority_donate_sema},
{"priority-donate-lower", test_priority_donate_lower},
{"priority-donate-chain", test_priority_donate_chain},
{"priority-fifo", test_priority_fifo},
{"priority-preempt", test_priority_preempt},
{"priority-sema", test_priority_sema},
{"priority-condvar", test_priority_condvar},
{"mlfqs-load-1", test_mlfqs_load_1},
{"mlfqs-load-60", test_mlfqs_load_60},
{"mlfqs-load-avg", test_mlfqs_load_avg},
{"mlfqs-recent-1", test_mlfqs_recent_1},
{"mlfqs-fair-2", test_mlfqs_fair_2},
{"mlfqs-fair-20", test_mlfqs_fair_20},
{"mlfqs-nice-2", test_mlfqs_nice_2},
{"mlfqs-nice-10", test_mlfqs_nice_10},
{"mlfqs-block", test_mlfqs_block},
}
test_func test_priority_donate_chain
test_func test_priority_fifo
Definition: priority-fifo.c:32
test_func test_alarm_multiple
Definition: alarm-wait.c:22
test_func test_priority_donate_nest
test_func test_priority_donate_lower
test_func test_alarm_zero
Tests timer_sleep(0), which should return immediately.
Definition: alarm-zero.c:11
test_func test_alarm_negative
Tests timer_sleep(-100).
test_func test_priority_condvar
test_func test_mlfqs_fair_20
Definition: mlfqs-fair.c:37
test_func test_alarm_simultaneous
test_func test_mlfqs_nice_2
Definition: mlfqs-fair.c:43
test_func test_priority_change
test_func test_priority_preempt
test_func test_mlfqs_nice_10
Definition: mlfqs-fair.c:49
test_func test_priority_donate_one
test_func test_alarm_single
Definition: alarm-wait.c:16
test_func test_priority_donate_multiple2
test_func test_priority_sema
Definition: priority-sema.c:16
test_func test_priority_donate_sema
test_func test_mlfqs_fair_2
Definition: mlfqs-fair.c:31
test_func test_mlfqs_block
Definition: mlfqs-block.c:23
test_func test_mlfqs_load_avg
test_func test_mlfqs_load_60
test_func test_mlfqs_load_1
Verifies that a single busy thread raises the load average to 0.5 in 38 to 45 seconds.
Definition: mlfqs-load-1.c:18
test_func test_mlfqs_recent_1
Checks that recent_cpu is calculated properly for the case of a single ready process.
test_func test_priority_donate_multiple
test_func test_alarm_priority

Definition at line 12 of file tests.c.

Referenced by run_test().