wm: teppich

Download patch

ref: 0c284ab6ef15350e506a90dfe2caca0a8849a24d
parent: 1a9e9aa22d5ea5a83bcdfc43b636c43dfb0c7ee8
author: mkf <mkf@cloud9p.org>
date: Thu Dec 7 06:28:28 EST 2023

check: add vga_test, put tests into a table

--- a/cmd/check.c
+++ b/cmd/check.c
@@ -2,15 +2,32 @@
 
 #include <u.h>
 #include <libc.h>
-
 #include <err.h>
+
 #include <mem.h>
+#include <vga.h>
+#include <ps2.h>
 
-void
+typedef struct
+{
+	char *name;
+	void (*fn)();
+}tbl;
+
+static void malloc_test(void);
+static void vga_test(void);
+
+static tbl tests[] =
+{
+	{"malloc", malloc_test},
+	{"vga", vga_test},
+};
+
+static void
 malloc_test(void)
 {
 	void *a, *b, *c;
-	 
+
 	a = malloc(1);
 	b = malloc(2);
 	c = malloc(3);
@@ -30,13 +47,57 @@
 	free(a);
 	free(b);
 	free(c);
+	memory_main(0, nil);
 }
 
+static void
+vga_test(void)
+{
+	char c, *s;
+	uint8 oldcolor;
+
+	s = malloc(10);
+	s = "Hello from VGA driver.\n";
+
+	vga_puts("vga_puts(): ");
+	vga_puts(s);
+	
+	vga_puts("vga_putc(): ");
+	for(int i = 0 ; i < strlen(s) ; i++)
+		vga_putc(s[i]);
+
+	vga_puts("dynamic \\t support:\n");
+	vga_puts("1\t  2\tabc\t   \td\n");
+
+	vga_puts("vga_writeto(): ");
+	for(int i = 0 ; i < strlen(s) ; i++)
+		vga_writeto(s[i], vga_color, vga_row, vga_col);
+	
+	vga_puts("\n");
+	oldcolor = vga_color;
+	vga_color = BLACK | RED << 4;
+	vga_puts("you should see this in color: ");
+	vga_puts(s);
+	vga_color = oldcolor;
+	
+	vga_puts("testing scroll");
+	vga_scroll();
+	
+	free(s);
+}
+
 int
-check_main(int argc, char **argv, char *cwd)
+check_main(int argc, char **argv)
 {
-	malloc_test();
-	printf("Press any key to quit test\n");
-	scanf("");
+	char c;
+
+	for(int i = 0 ; i < (sizeof(tests) / sizeof(tbl)) ; i++)
+	{
+		vga_clear(' ');
+		printf("%s test\n", tests[i].name);
+		tests[i].fn();
+		printf("press any key to continue\n");
+		scanf("%c", &c);
+	}
 	return OK;
 }