Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| ce54a4282b |
4 changed files with 365 additions and 320 deletions
|
|
@ -1,93 +0,0 @@
|
|||
#ifndef DOUBLY_LINKED_LIST_TEST_H
|
||||
#define DOUBLY_LINKED_LIST_TEST_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "scheduler.h"
|
||||
|
||||
// External declarations of your implemented functions
|
||||
bool stud_rq_empty(struct run_queue const *rq);
|
||||
struct task *stud_task_create(int pid, enum states state);
|
||||
void stud_task_free(struct task *task);
|
||||
void stud_rq_destroy(struct run_queue *rq);
|
||||
struct task *stud_rq_find(struct run_queue *rq, int pid);
|
||||
struct task *stud_rq_head(struct run_queue *rq);
|
||||
struct task *stud_rq_tail(struct run_queue *rq);
|
||||
bool stud_rq_enqueue(struct run_queue *rq, struct task *task);
|
||||
bool stud_rq_prepend(struct run_queue *rq, struct task *task);
|
||||
size_t stud_rq_length(struct run_queue *rq);
|
||||
|
||||
// Helper to print queue exactly like the VPL server
|
||||
static void print_rq(struct run_queue *rq) {
|
||||
if (stud_rq_empty(rq)) {
|
||||
printf("END\n");
|
||||
return;
|
||||
}
|
||||
struct task *curr = rq->head;
|
||||
do {
|
||||
const char *state_str = (curr->state == READY) ? "ready" :
|
||||
(curr->state == RUNNING) ? "running" :
|
||||
(curr->state == BLOCKED) ? "blocked" : "terminated";
|
||||
printf("{ id = %d, state = %s, runtime = %d } -- ", curr->pid, state_str, curr->runtime);
|
||||
curr = curr->next;
|
||||
} while (curr != rq->head);
|
||||
printf("END\n");
|
||||
}
|
||||
|
||||
void test_rq_empty() { /* omitted for brevity, passing */ }
|
||||
void test_rq_head() { /* omitted for brevity, passing */ }
|
||||
void test_rq_length() { /* omitted for brevity, passing */ }
|
||||
|
||||
// Crash line 128 in your log
|
||||
void test_rq_destroy() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
stud_rq_enqueue(&rq, stud_task_create(1, READY));
|
||||
stud_rq_enqueue(&rq, stud_task_create(2, READY));
|
||||
|
||||
// Line 128
|
||||
stud_rq_destroy(&rq);
|
||||
assert(stud_rq_empty(&rq));
|
||||
}
|
||||
|
||||
// Crash line 143 in your log
|
||||
void test_rq_find() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
|
||||
// Line 143: This causes your code to segfault because rq is empty
|
||||
// and stud_rq_find attempts to dereference NULL.
|
||||
struct task *t = stud_rq_find(&rq, 99);
|
||||
assert(t == NULL);
|
||||
}
|
||||
|
||||
// Crash line 186 in your log
|
||||
void test_rq_tail() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
stud_rq_enqueue(&rq, stud_task_create(1, READY));
|
||||
stud_rq_enqueue(&rq, stud_task_create(2, READY));
|
||||
struct task *tail = stud_rq_tail(&rq);
|
||||
|
||||
// Line 186
|
||||
assert(tail && tail->pid == 2);
|
||||
}
|
||||
|
||||
void test_rq_enqueue() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
printf("add tasks 1-4\n");
|
||||
stud_rq_enqueue(&rq, stud_task_create(1, READY));
|
||||
stud_rq_enqueue(&rq, stud_task_create(2, READY));
|
||||
stud_rq_enqueue(&rq, stud_task_create(3, READY));
|
||||
stud_rq_enqueue(&rq, stud_task_create(4, READY));
|
||||
print_rq(&rq);
|
||||
stud_rq_destroy(&rq); // This triggers your double free!
|
||||
}
|
||||
|
||||
// Crash line 201 in your log
|
||||
void test_rq_prepend() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
printf("add tasks 1-4\n");
|
||||
stud_rq_enqueue(&rq, stud_task_create(2, READY));
|
||||
|
||||
// Line 201: Prepending causes your segfault here.
|
||||
stud_rq_prepend(&rq, stud_task_create(1, READY));
|
||||
}
|
||||
|
||||
#endif // DOUBLY_LINKED_LIST_TEST_H
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
#ifndef SCHEDULER_ROUND_ROBIN_TEST_H
|
||||
#define SCHEDULER_ROUND_ROBIN_TEST_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "scheduler.h"
|
||||
|
||||
void stud_RR_start(struct run_queue *rq, int pid);
|
||||
void stud_RR_elect(struct run_queue *rq);
|
||||
void stud_RR_terminate(struct run_queue *rq);
|
||||
void stud_RR_clock_tick(struct run_queue *rq);
|
||||
void stud_RR_wait(struct run_queue *rq);
|
||||
void stud_RR_wake_up(struct run_queue *rq, int pid);
|
||||
void stud_RR(struct run_queue* rq, enum events event, int pid);
|
||||
|
||||
// Mock implementation of the grader's verifier
|
||||
bool rq_eq(struct run_queue *sol, struct run_queue *stu) {
|
||||
if (sol->n_tasks != stu->n_tasks) return false;
|
||||
if (sol->n_tasks == 0) return true;
|
||||
|
||||
struct task *c1 = sol->head;
|
||||
struct task *c2 = stu->head;
|
||||
int pos = 0;
|
||||
do {
|
||||
if (c1->pid != c2->pid || c1->state != c2->state) {
|
||||
fprintf(stderr, "Task (%d, %s) error at position %d\n",
|
||||
c2->pid, c2->state == RUNNING ? "running" : "other", pos);
|
||||
return false;
|
||||
}
|
||||
c1 = c1->next;
|
||||
c2 = c2->next;
|
||||
pos++;
|
||||
} while (c1 != sol->head && c2 != stu->head);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Crash line 73 in your log
|
||||
void test_RR_start() {
|
||||
struct run_queue stu = {NULL, 0, 0};
|
||||
struct run_queue sol = {NULL, 0, 0}; // Mock expected state
|
||||
|
||||
// Manually build expected solution queue to compare against
|
||||
stud_rq_enqueue(&sol, stud_task_create(1, RUNNING));
|
||||
stud_rq_enqueue(&sol, stud_task_create(2, READY));
|
||||
stud_rq_enqueue(&sol, stud_task_create(3, READY));
|
||||
|
||||
printf("add task 1\n");
|
||||
stud_RR_start(&stu, 1);
|
||||
|
||||
printf("add task 2\n");
|
||||
stud_RR_start(&stu, 2);
|
||||
|
||||
printf("add task 3\n");
|
||||
stud_RR_start(&stu, 3);
|
||||
|
||||
printf("add task 1 again\n");
|
||||
stud_RR_start(&stu, 1);
|
||||
|
||||
print_rq(&stu);
|
||||
|
||||
// Line 73
|
||||
assert(rq_eq(&sol, &stu));
|
||||
}
|
||||
|
||||
// Helper to prepopulate a specific queue state for testing the crash logs
|
||||
void prepopulate_queue(struct run_queue *rq) {
|
||||
stud_rq_enqueue(rq, stud_task_create(1, RUNNING));
|
||||
stud_rq_enqueue(rq, stud_task_create(2, TERMINATED));
|
||||
stud_rq_enqueue(rq, stud_task_create(3, READY));
|
||||
stud_rq_enqueue(rq, stud_task_create(4, TERMINATED));
|
||||
stud_rq_enqueue(rq, stud_task_create(8, READY));
|
||||
stud_rq_enqueue(rq, stud_task_create(14, BLOCKED));
|
||||
}
|
||||
|
||||
// Crash line 109 in your log
|
||||
void test_RR_elect_running() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
prepopulate_queue(&rq);
|
||||
print_rq(&rq);
|
||||
printf("electing new task...\n");
|
||||
|
||||
// Line 109
|
||||
stud_RR_elect(&rq);
|
||||
}
|
||||
|
||||
// Crash line 127 in your log
|
||||
void test_RR_elect_blocked() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
prepopulate_queue(&rq);
|
||||
rq.head->state = BLOCKED; // Change 1 to blocked
|
||||
print_rq(&rq);
|
||||
printf("electing new task...\n");
|
||||
|
||||
// Line 127
|
||||
stud_RR_elect(&rq);
|
||||
}
|
||||
|
||||
// Crash line 148 in your log
|
||||
void test_RR_terminate() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
prepopulate_queue(&rq);
|
||||
print_rq(&rq);
|
||||
printf("task terminating...\n");
|
||||
|
||||
// Line 148
|
||||
stud_RR_terminate(&rq);
|
||||
}
|
||||
|
||||
// Crash line 169 in your log
|
||||
void test_RR_wait() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
prepopulate_queue(&rq);
|
||||
print_rq(&rq);
|
||||
printf("task is waiting...\n");
|
||||
|
||||
// Line 169
|
||||
stud_RR_wait(&rq);
|
||||
}
|
||||
|
||||
// Crash line 190 in your log
|
||||
void test_RR_wake_up() {
|
||||
struct run_queue rq = {NULL, 0, 0};
|
||||
prepopulate_queue(&rq);
|
||||
print_rq(&rq);
|
||||
printf("task 14 waking up...\n");
|
||||
|
||||
// Line 190
|
||||
stud_RR_wake_up(&rq, 14);
|
||||
}
|
||||
|
||||
// Crash line 216 in your log
|
||||
void test_RR_clock_tick() {
|
||||
struct run_queue stu = {NULL, 0, 0};
|
||||
prepopulate_queue(&stu);
|
||||
print_rq(&stu);
|
||||
|
||||
for(int i=0; i<10; i++) {
|
||||
printf("running clock tick...\n");
|
||||
stud_RR_clock_tick(&stu);
|
||||
}
|
||||
|
||||
print_rq(&stu);
|
||||
|
||||
struct run_queue sol = {NULL, 0, 0};
|
||||
// Expected solution queue state omitted for brevity
|
||||
|
||||
// Line 216
|
||||
// assert(rq_eq(&sol, &stu));
|
||||
}
|
||||
|
||||
// Crash line 263 in your log
|
||||
void test_RR_scripted_1() {
|
||||
struct run_queue stu = {NULL, 0, 0};
|
||||
prepopulate_queue(&stu);
|
||||
print_rq(&stu);
|
||||
for(int i=0; i<5; i++) {
|
||||
printf("running clock tick...\n");
|
||||
stud_RR_clock_tick(&stu);
|
||||
}
|
||||
print_rq(&stu);
|
||||
printf("task is waiting...\n");
|
||||
|
||||
// Line 263
|
||||
stud_RR(&stu, wait, 0);
|
||||
}
|
||||
|
||||
#endif // SCHEDULER_ROUND_ROBIN_TEST_H
|
||||
365
test_example.md
Normal file
365
test_example.md
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
Running test: ./vpl_execution 0 empty
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 0 head
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 0 tail
|
||||
vpl_execution: doubly_linked_list_test.h:186: test_rq_tail: Assertion `tail && tail->pid == 2' failed.
|
||||
Test killed by signal Aborted
|
||||
|
||||
Running test: ./vpl_execution 0 enqueue
|
||||
add tasks 1-4
|
||||
{ id = 1, state = ready, runtime = 0 } -- { id = 2, state = ready, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = ready, runtime = 0 } -- END
|
||||
free(): double free detected in tcache 2
|
||||
Test killed by signal Aborted
|
||||
|
||||
Running test: ./vpl_execution 0 prepend
|
||||
add tasks 1-4
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7fcfd0cc0c30 ?? ??:0
|
||||
2: 0x403de8 stud_rq_prepend at /home/p10758/doubly_linked_list.c:209
|
||||
3: 0x40b336 test_rq_prepend at /home/p10758/doubly_linked_list_test.h:201
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7fcfd0cab610 ?? ??:0
|
||||
7: 0x7fcfd0cab6c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 0 find
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: (nil)
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7f868e1c9c30 ?? ??:0
|
||||
2: 0x403adc stud_rq_find at /home/p10758/doubly_linked_list.c:84
|
||||
3: 0x40b059 test_rq_find at /home/p10758/doubly_linked_list_test.h:143
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7f868e1b4610 ?? ??:0
|
||||
7: 0x7f868e1b46c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 0 length
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 0 destroy
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7f6ddbfd5c30 ?? ??:0
|
||||
2: 0x403a62 stud_rq_destroy at /home/p10758/doubly_linked_list.c:61 (discriminator 1)
|
||||
3: 0x40aefa test_rq_destroy at /home/p10758/doubly_linked_list_test.h:128
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7f6ddbfc0610 ?? ??:0
|
||||
7: 0x7f6ddbfc06c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 3 start
|
||||
err: a task with pid 1 already exists in the runqueue
|
||||
add task 1
|
||||
{ id = 1, state = running, runtime = 0 } -- END
|
||||
add task 2
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = ready, runtime = 0 } -- END
|
||||
add task 3
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = ready, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- END
|
||||
add task 1 again
|
||||
err: a task with pid 1 already exists in the runqueue
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = ready, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- END
|
||||
Task (1, running) error at position 0
|
||||
vpl_execution: scheduler_round_robin_test.h:73: test_RR_start: Assertion `rq_eq(&sol, &stu)' failed.
|
||||
Test killed by signal Aborted
|
||||
|
||||
Running test: ./vpl_execution 3 clock_tick
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
{ id = 3, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
Error while iterating over the list
|
||||
vpl_execution: scheduler_round_robin_test.h:216: test_RR_clock_tick: Assertion `rq_eq(&sol, &stu)' failed.
|
||||
Test killed by signal Aborted
|
||||
|
||||
Running test: ./vpl_execution 3 elect_blocked
|
||||
{ id = 1, state = blocked, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- END
|
||||
electing new task...
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7fa0ec7c2c30 ?? ??:0
|
||||
2: 0x403558 stud_RR_elect at /home/p10758/scheduler_round_robin.c:66
|
||||
3: 0x409891 test_RR_elect_blocked at /home/p10758/scheduler_round_robin_test.h:127
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7fa0ec7ad610 ?? ??:0
|
||||
7: 0x7fa0ec7ad6c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 3 elect_running
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
electing new task...
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7fb07a1b9c30 ?? ??:0
|
||||
2: 0x403558 stud_RR_elect at /home/p10758/scheduler_round_robin.c:66
|
||||
3: 0x409748 test_RR_elect_running at /home/p10758/scheduler_round_robin_test.h:109
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7fb07a1a4610 ?? ??:0
|
||||
7: 0x7fb07a1a46c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 3 terminate
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
task terminating...
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7fdb2653dc30 ?? ??:0
|
||||
2: 0x40362d stud_RR_terminate at /home/p10758/scheduler_round_robin.c:95
|
||||
3: 0x4099f2 test_RR_terminate at /home/p10758/scheduler_round_robin_test.h:148
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7fdb26528610 ?? ??:0
|
||||
7: 0x7fdb265286c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 3 wait
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
task is waiting...
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7f18b339bc30 ?? ??:0
|
||||
2: 0x4037a8 stud_RR_wait at /home/p10758/scheduler_round_robin.c:147
|
||||
3: 0x409b53 test_RR_wait at /home/p10758/scheduler_round_robin_test.h:169
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7f18b3386610 ?? ??:0
|
||||
7: 0x7f18b33866c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 3 wake_up
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
task 14 waking up...
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x8
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7f026f040c30 ?? ??:0
|
||||
2: 0x4038a3 stud_RR_wake_up at /home/p10758/scheduler_round_robin.c:173
|
||||
3: 0x409cbe test_RR_wake_up at /home/p10758/scheduler_round_robin_test.h:190
|
||||
4: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
5: 0x415566 main at /home/p10758/tests.c:409
|
||||
6: 0x7f026f02b610 ?? ??:0
|
||||
7: 0x7f026f02b6c0 ?? ??:0
|
||||
8: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 3 scripted_1
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
running clock tick...
|
||||
{ id = 1, state = running, runtime = 0 } -- { id = 2, state = terminated, runtime = 0 } -- { id = 3, state = ready, runtime = 0 } -- { id = 4, state = terminated, runtime = 0 } -- { id = 8, state = ready, runtime = 0 } -- { id = 14, state = blocked, runtime = 0 } -- END
|
||||
task is waiting...
|
||||
|
||||
=== Caught signal 11 (Segmentation fault) ===
|
||||
Faulty address: 0x10
|
||||
|
||||
Stack trace with source locations:
|
||||
0: 0x414b3d segv_handler at /home/p10758/tests.c:211
|
||||
1: 0x7f6a9d552c30 ?? ??:0
|
||||
2: 0x4037a8 stud_RR_wait at /home/p10758/scheduler_round_robin.c:147
|
||||
3: 0x403988 stud_RR at /home/p10758/scheduler_round_robin.c:214
|
||||
4: 0x40a27b test_RR_scripted_1 at /home/p10758/scheduler_round_robin_test.h:263
|
||||
5: 0x41495b run_test_and_checks at /home/p10758/tests.c:146
|
||||
6: 0x415566 main at /home/p10758/tests.c:409
|
||||
7: 0x7f6a9d53d610 ?? ??:0
|
||||
8: 0x7f6a9d53d6c0 ?? ??:0
|
||||
9: 0x403285 _start at ??:?
|
||||
exit()/exec() detected (test did not return to harness)
|
||||
|
||||
Running test: ./vpl_execution 4 fcfs_long_job
|
||||
Expected Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 2 2 3 3 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 2 2 3 3 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 fcfs_zero_runtime
|
||||
Expected Schedule:
|
||||
2 2 2 2 2 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
2 2 2 2 2 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 fcfs_long_job_random
|
||||
Expected Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 3 3 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 fcfs_zero_runtime_random
|
||||
Expected Schedule:
|
||||
2 2 2 2 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
2 2 2 2 3 3 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 fcfs_random
|
||||
Expected Schedule:
|
||||
0 0 3 3 3 0 0 4 4 4 4 4 4 2 2 2 2 2 2 1 1 1 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
0 0 3 3 3 0 0 4 4 4 4 4 4 2 2 2 2 2 2 1 1 1 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_non_preemptive
|
||||
Expected Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_same_runtime
|
||||
Expected Schedule:
|
||||
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_long_job_starvation
|
||||
Expected Schedule:
|
||||
2 3 4 5 6 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
2 3 4 5 6 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_all_zero_arrival
|
||||
Expected Schedule:
|
||||
2 3 3 4 4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
2 3 3 4 4 4 4 4 4 4 4 4 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_non_preemptive_random
|
||||
Expected Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_same_runtime_random
|
||||
Expected Schedule:
|
||||
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_long_job_starvation_random
|
||||
Expected Schedule:
|
||||
2 3 4 5 6 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
2 3 4 5 6 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_all_zero_arrival_random
|
||||
Expected Schedule:
|
||||
1 1 1 1 3 3 3 3 3 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
Your Schedule:
|
||||
1 1 1 1 3 3 3 3 3 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
||||
Test passed!
|
||||
|
||||
|
||||
Running test: ./vpl_execution 4 sjf_random
|
||||
[DEBUG] test_sched_sjf_random invoked
|
||||
Test passed!
|
||||
|
||||
|
||||
Comment :=>> Some tests failed:
|
||||
- 0 tail
|
||||
- 0 enqueue
|
||||
- 0 prepend
|
||||
- 0 find
|
||||
- 0 destroy
|
||||
- 3 start
|
||||
- 3 clock_tick
|
||||
- 3 elect_blocked
|
||||
- 3 elect_running
|
||||
- 3 terminate
|
||||
- 3 wait
|
||||
- 3 wake_up
|
||||
- 3 scripted_1
|
||||
|
||||
|
||||
61
tests.c
61
tests.c
|
|
@ -1,61 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <unistd.h>
|
||||
#include "scheduler.h"
|
||||
#include "doubly_linked_list_test.h"
|
||||
#include "scheduler_round_robin_test.h"
|
||||
|
||||
// Replicates the crash handler from tests.c:211
|
||||
void segv_handler(int sig) {
|
||||
void *array[10];
|
||||
size_t size;
|
||||
fprintf(stderr, "\n=== Caught signal %d (Segmentation fault) ===\n", sig);
|
||||
size = backtrace(array, 10);
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
fprintf(stderr, "exit()/exec() detected (test did not return to harness)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Replicates the test routing from tests.c:146
|
||||
void run_test_and_checks(int suite, const char *test_name) {
|
||||
if (suite == 0) {
|
||||
if (strcmp(test_name, "empty") == 0) test_rq_empty();
|
||||
else if (strcmp(test_name, "head") == 0) test_rq_head();
|
||||
else if (strcmp(test_name, "tail") == 0) test_rq_tail();
|
||||
else if (strcmp(test_name, "enqueue") == 0) test_rq_enqueue();
|
||||
else if (strcmp(test_name, "prepend") == 0) test_rq_prepend();
|
||||
else if (strcmp(test_name, "find") == 0) test_rq_find();
|
||||
else if (strcmp(test_name, "length") == 0) test_rq_length();
|
||||
else if (strcmp(test_name, "destroy") == 0) test_rq_destroy();
|
||||
} else if (suite == 3) {
|
||||
if (strcmp(test_name, "start") == 0) test_RR_start();
|
||||
else if (strcmp(test_name, "clock_tick") == 0) test_RR_clock_tick();
|
||||
else if (strcmp(test_name, "elect_blocked") == 0) test_RR_elect_blocked();
|
||||
else if (strcmp(test_name, "elect_running") == 0) test_RR_elect_running();
|
||||
else if (strcmp(test_name, "terminate") == 0) test_RR_terminate();
|
||||
else if (strcmp(test_name, "wait") == 0) test_RR_wait();
|
||||
else if (strcmp(test_name, "wake_up") == 0) test_RR_wake_up();
|
||||
else if (strcmp(test_name, "scripted_1") == 0) test_RR_scripted_1();
|
||||
}
|
||||
printf("Test passed!\n");
|
||||
}
|
||||
|
||||
// Replicates tests.c:409
|
||||
int main(int argc, char **argv) {
|
||||
signal(SIGSEGV, segv_handler);
|
||||
signal(SIGABRT, segv_handler);
|
||||
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: ./vpl_execution <suite_id> <test_name>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int suite = atoi(argv[1]);
|
||||
const char *test_name = argv[2];
|
||||
|
||||
run_test_and_checks(suite, test_name);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue