Made freestanding; tests removed - 's for libc.a

This commit is contained in:
Gitea 2020-12-21 12:56:24 -06:00
parent c79e957f38
commit abf1964953

View file

@ -1,104 +1,10 @@
#include <kernel/init.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/io.h>
#include "gdt.h"
int tss[16][2];
int test_libc(void) {
int failed = 0;
printf("==Testing stdio.h==\n");
printf("printf(\"%%d\", 10): %d (expected 10)\n", 10);
printf("printf(\"%%o\", 14): %o (expected 16)\n", 14);
printf("printf(\"%%u\", 10): %u (expected 10)\n", 10);
printf("printf(\"%%x\", 26): %x (expected 1a)\n", 26);
printf("printf(\"%%X\", 0xC9A): %x (expected C9A)\n", 0xC9A);
printf("printf(\"%%p\", &i): %p (expected 0x[hex])\n", &failed);
printf("printf(\"%%n\"): %n (expected 14)\n");
printf("==Testing math.h==\n");
if(cos(0) == 1.0) {
printf("[");
/* I want the status to be coloured. How do I do that? */
printf("OK");
printf("] cos()\n");
}
else {
printf("[");
printf("FAIL");
printf("] cos()\n");
failed++;
}
if(fabs(-2.3) == 2.3) {
printf("[");
printf("OK");
printf("] fabs()\n");
}
else {
printf("[");
printf("FAIL");
printf("] fabs()\n");
failed++;
}
printf("==Testing time.h==\n");
printf("time(0): Current UNIX time: %d\n", time(0));
printf("==Testing stdlib.h==\n");
if(abs(-5) == 5) {
printf("[");
printf("OK");
printf("] abs()\n");
}
else {
printf("[");
printf("FAIL");
printf("] abs(); expected 5, got %d\n", abs(-5));
failed++;
}
srand(time(0));
int rand_test = rand();
printf("rand() output with seed time(0): %d\n", rand_test);
printf("==Testing string.h==\n");
if(strcmp("Hi", "Hi") == 0 && strcmp("Hi", "Hello") != 0) {
printf("[");
printf("OK");
printf("] strcmp()\n");
}
else {
printf("[");
printf("FAIL");
printf("] strcmp()\n");
failed++;
}
if(strcspn("Hello!", "!e") == 1) {
printf("[");
printf("OK");
printf("] strcspn()\n");
}
else {
printf("[");
printf("FAIL");
printf("] strcspn(); expected 1, got %d\n", strcspn("Hello!", "!e"));
failed++;
}
printf("Tests failed: %d\n", failed);
return failed;
}
void NMI_disable(void) {
outb(0x70, inb(0x70) | 0x80);
}
@ -138,5 +44,4 @@ int init(void) {
A20_enable();
setup_gdt();
printf("Fenix Dev Pre-release v0.0.3\n");
return test_libc();
}