Exemplo n.º 1
0
int main() {
    LIST *jlist = init_list();

    assert(gen_job_id(jlist) == 1);
    assert(get_fg(jlist) == (job *)NULL);
    assert(jlist->size == 0);

    //print_bg(jlist);
    
    job *jb1 = tstjob(1);
    push(jlist, JOB, jb1);
    assert(gen_job_id(jlist) == 2);
    assert(get_fg(jlist) == jb1);

    //print_bg(jlist);

    job *jb2 = tstjob(3);
    push(jlist, JOB, jb2);
    assert(gen_job_id(jlist) == 2);

    job *jb3 = tstjob(2);
    push(jlist, JOB, jb3);
    assert(gen_job_id(jlist) == 4);

    push(jlist, JOB, tstjob(7));
    assert(gen_job_id(jlist) == 4);

    print_bg(jlist);

    pop(jlist);
    assert(gen_job_id(jlist) == 4);

    assert(get_job_pgid(jlist, 11) == (job *)NULL);
    assert(get_job_pgid(jlist, 7) == jb2);
    assert(get_job_pgid(jlist, 3) == jb3);
    assert(get_job(jlist, 3) == jb2);
    assert(del_job(jlist, 7) == jb2);
    assert(get_job(jlist, 3) == (job *)NULL);
    assert(get_job(jlist, 55) == jb3);
    assert(get_job(jlist, 10) == (job *)NULL);
    assert(set_complete(jb2, 3) == 0);
    assert(set_complete(jb2, 4) == -1);
    assert(set_complete(jb3, 55) == 0);
    assert(((process *)jb2->pid_list->head->node_ptr)->complete == 0);
    assert(jb2->complete == 0);
    assert(jb3->complete == 1);
    assert(jlist->size == 2);
    assert(get_job_jid(jlist, 1) == jb1);
    assert(get_job_jid(jlist, 11) == (job *)NULL);

    printf("[job_handler_tst] All tests pass!\n");
    return 0;
}
Exemplo n.º 2
0
// Shift the text several lines up the screen
void VGA_Text_Buffer::scroll(size_t lines, vga_color fill) {
  for (size_t row = 0; row + lines < rows; ++row) {
    for (size_t col = 0; col < cols; ++ col) {
      at(row,col) = at(row+lines,col);
    }
  }

  // Save the color
  vga_color bg = get_bg();
  vga_color fg = get_fg();
  // Make the foreground and background the same color
  set_color(fill,fill);
  for (size_t row = rows > lines ? rows - lines : 0;
       row < rows;
       ++row) {
    for (size_t col = 0; col < cols; ++col) {
      at(row,col) = make_entry(' ');
    }
  }
  // Restore the color
  set_color(fg,bg);
  row = row >= lines ? row - lines : 0;
}