Skip to content

Commit

Permalink
Merge pull request #30 from pbrucla/unit_testing
Browse files Browse the repository at this point in the history
Unit testing
  • Loading branch information
danieltherealyang authored Dec 1, 2023
2 parents c0f2556 + ebb7968 commit 097130a
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/boot/disk_load.asm
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ disk_load:

DISK_ERROR_MSG db "? - Disk read error!",0
WOOT db "woot",0
WOOT db "woot",0
1 change: 1 addition & 0 deletions source/kernel/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ void main()
terminal_update_cursor();
init_idt();
init_paging();
printRegs();
}
4 changes: 3 additions & 1 deletion source/libc/include/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ void outb(unsigned short port, unsigned char value);
void io_wait();
// printf attached to terminal for now
int printf(const char *s, ...);
int printch(char c);
int printch(char c);
void unitTest(const int errorNum,const char* errorMessage, const int bool);
void PrintRegs();
54 changes: 53 additions & 1 deletion source/libc/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,56 @@ int printch(char c)
{
terminal_putchar(c);
terminal_update_cursor();
}
}

void unitTest(const int errorNum,const char* errorMessage, const int bool){
terminal_put64(errorNum);
terminal_putchar(':');
terminal_putchar(' ');
printf(errorMessage);

if(bool==1) asm("hlt");
}

void printRegs(){
int i;
asm("mov %%eax, %0" : "+g" (i)::);
printf("eax: ");
terminal_put64(i);
printf("\n");

asm("mov %%ebx, %0" : "+g" (i)::);
printf("ebx: ");
terminal_put64(i);
printf("\n");

asm("mov %%ecx, %0" : "+g" (i)::);
printf("ecx: ");
terminal_put64(i);
printf("\n");

asm("mov %%edx, %0" : "+g" (i)::);
printf("edx: ");
terminal_put64(i);
printf("\n");

asm("mov %%esi, %0" : "+g" (i)::);
printf("esi: ");
terminal_put64(i);
printf("\n");

asm("mov %%edi, %0" : "+g" (i)::);
printf("edi: ");
terminal_put64(i);
printf("\n");

asm("mov %%ebp, %0" : "+g" (i)::);
printf("ebp: ");
terminal_put64(i);
printf("\n");

asm("mov %%esp, %0" : "+g" (i)::);
printf("esp: ");
terminal_put64(i);
printf("\n");
}

0 comments on commit 097130a

Please sign in to comment.