summaryrefslogtreecommitdiff
path: root/gpxe/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'gpxe/src/tests')
-rw-r--r--gpxe/src/tests/comboot/shuffle-simple.asm40
-rw-r--r--gpxe/src/tests/comboot/version.asm136
-rw-r--r--gpxe/src/tests/gdbstub_test.S54
-rwxr-xr-xgpxe/src/tests/gdbstub_test.gdb116
-rw-r--r--gpxe/src/tests/linebuf_test.c35
-rw-r--r--gpxe/src/tests/memcpy_test.c39
-rw-r--r--gpxe/src/tests/umalloc_test.c26
-rw-r--r--gpxe/src/tests/uri_test.c148
8 files changed, 0 insertions, 594 deletions
diff --git a/gpxe/src/tests/comboot/shuffle-simple.asm b/gpxe/src/tests/comboot/shuffle-simple.asm
deleted file mode 100644
index efc7d9b4..00000000
--- a/gpxe/src/tests/comboot/shuffle-simple.asm
+++ /dev/null
@@ -1,40 +0,0 @@
- bits 16
- org 100h
-
- jmp start
-
-shuffle_start:
- push 0xB800
- pop es
- mov cx, 80*24*2
- mov ax, 'AA'
- xor di, di
- rep stosw
-.lbl: jmp .lbl
-shuffle_end:
- nop
-shuffle_len equ (shuffle_end - shuffle_start + 1)
-
-start:
- ; calculate physical address of shuffled part
- xor eax, eax
- push ds
- pop ax
- shl eax, 4
- add ax, shuffle_start
- mov dword [source], eax
-
- mov ax, 0012h
- mov di, shuffle_descriptors
- mov cx, num_shuffle_descriptors
- mov ebp, 0x7c00
- int 22h
- int3
-
-shuffle_descriptors:
- dd 0x7C00
-source: dd 0
- dd shuffle_len
-
-num_shuffle_descriptors equ 1
-
diff --git a/gpxe/src/tests/comboot/version.asm b/gpxe/src/tests/comboot/version.asm
deleted file mode 100644
index 01140423..00000000
--- a/gpxe/src/tests/comboot/version.asm
+++ /dev/null
@@ -1,136 +0,0 @@
- bits 16
- org 100h
-
-_start:
- ; first check for SYSLINUX
- mov ah, 30h
- int 21h
-
- cmp eax, 59530000h
- jne .not_syslinux
- cmp ebx, 4c530000h
- jne .not_syslinux
- cmp ecx, 4e490000h
- jne .not_syslinux
- cmp edx, 58550000h
- jne .not_syslinux
-
- ; now get syslinux version
- mov ax, 0001h
- int 22h
-
- push cx
- push dx
- push di
- push si
- push es
-
- ; print version string
- mov dx, str_version
- mov ah, 09h
- int 21h
-
- pop es
- pop bx
- push es
- mov ax, 0002h
- int 22h
-
- ; print copyright string
- mov dx, str_copyright
- mov ah, 09h
- int 21h
-
- pop es
- pop bx
- mov ax, 0002h
- int 22h
-
- ; print syslinux derivative id
- mov dx, str_derivative
- mov ah, 09h
- int 21h
-
- pop ax
- call print_hex_byte
-
- ; print version number
- mov dx, str_version_num
- mov ah, 09h
- int 21h
-
- pop cx
- push cx
- mov ax, cx
- and ax, 0FFh
- call print_dec_word
-
- mov dl, '.'
- mov ah, 02h
- int 21h
-
- pop cx
- mov ax, cx
- shr ax, 8
- call print_dec_word
-
- ret
-
-
-.not_syslinux:
- mov dx, str_not_syslinux
- mov ah, 09h
- int 21h
- ret
-
-; input: al = byte to print in hex
-print_hex_byte:
- push ax
- shr al, 4
- call print_hex_nybble
- pop ax
- call print_hex_nybble
- ret
-
-; input: bottom half of al = nybble to print in hex
-print_hex_nybble:
- push ax
- mov bl, al
- and bx, 1111b
- mov dl, [str_hex + bx]
- mov ah, 02h
- int 21h
- pop ax
- ret
-
-str_hex: db "01234567890abcdef"
-
-; input: ax = word to print
-print_dec_word:
- mov cx, 10
- mov word [.count], 0
-.loop:
- xor dx, dx
- div cx
- inc word [.count]
- push dx
- test ax, ax
- jnz .loop
-
-.print:
- pop dx
- add dx, '0'
- mov ah, 02h
- int 21h
- dec word [.count]
- jnz .print
-
- ret
-
-.count: dw 0
-
-str_not_syslinux: db "Not SYSLINUX or derivative (running on DOS?)$"
-str_version: db "Version: $"
-str_copyright: db 10, "Copyright: $"
-str_derivative: db 10, "Derivative ID: 0x$"
-str_version_num: db 10, "Version number: $"
diff --git a/gpxe/src/tests/gdbstub_test.S b/gpxe/src/tests/gdbstub_test.S
deleted file mode 100644
index 739b0527..00000000
--- a/gpxe/src/tests/gdbstub_test.S
+++ /dev/null
@@ -1,54 +0,0 @@
- .arch i386
-
- .section ".data", "aw", @progbits
-watch_me:
- .long 0xfeedbeef
-
- .section ".text", "ax", @progbits
- .code32
-gdbstub_test:
- /* 1. Read registers test */
- movl $0xea010203, %eax
- movl $0xeb040506, %ebx
- movl $0xec070809, %ecx
- movl $0xed0a0b0c, %edx
- movl $0x510d0e0f, %esi
- movl $0xd1102030, %edi
- int $3
-
- /* 2. Write registers test */
- int $3
-
- /* 3. Read memory test */
- subl $8, %esp
- movl $0x11223344, 4(%esp)
- movw $0x5566, 2(%esp)
- movb $0x77, (%esp)
- int $3
-
- /* 4. Write memory test */
- int $3
- addl $8, %esp
-
- /* 5. Step test */
- int $3
- nop
-
- /* 6. Access watch test */
- movl $0x600d0000, %ecx
- movl watch_me, %eax
- movl $0xbad00000, %ecx
- int $3
- movl $0x600d0001, %ecx
- movl %eax, watch_me
- movl $0xbad00001, %ecx
- int $3
-
- /* 7. Write watch test */
- movl $0x600d0002, %ecx
- movl %eax, watch_me
- movl $0xbad00002, %ecx
- int $3
-
-1:
- jmp 1b
diff --git a/gpxe/src/tests/gdbstub_test.gdb b/gpxe/src/tests/gdbstub_test.gdb
deleted file mode 100755
index 52aa693f..00000000
--- a/gpxe/src/tests/gdbstub_test.gdb
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/gdb -x
-# Test suite for GDB remote debugging
-# Run:
-# make bin/gpxe.hd.tmp
-# make
-# gdb
-# (gdb) target remote :TCPPORT
-# OR
-# (gdb) target remote udp:IP:UDPPORT
-# (gdb) source tests/gdbstub_test.gdb
-
-define gpxe_load_symbols
- file bin/gpxe.hd.tmp
-end
-
-define gpxe_assert
- if $arg0 != $arg1
- echo FAIL $arg2\n
- else
- echo PASS $arg2\n
- end
-end
-
-define gpxe_start_tests
- jump gdbstub_test
-end
-
-define gpxe_test_regs_read
- gpxe_assert $eax 0xea010203 "gpxe_test_regs_read eax"
- gpxe_assert $ebx 0xeb040506 "gpxe_test_regs_read ebx"
- gpxe_assert $ecx 0xec070809 "gpxe_test_regs_read ecx"
- gpxe_assert $edx 0xed0a0b0c "gpxe_test_regs_read edx"
- gpxe_assert $esi 0x510d0e0f "gpxe_test_regs_read esi"
- gpxe_assert $edi 0xd1102030 "gpxe_test_regs_read edi"
-end
-
-define gpxe_test_regs_write
- set $eax = 0xea112233
- set $ebx = 0xeb445566
- set $ecx = 0xec778899
- set $edx = 0xedaabbcc
- set $esi = 0x51ddeeff
- set $edi = 0xd1010203
- c
- gpxe_assert $eax 0xea112233 "gpxe_test_regs_write eax"
- gpxe_assert $ebx 0xeb445566 "gpxe_test_regs_write ebx"
- gpxe_assert $ecx 0xec778899 "gpxe_test_regs_write ecx"
- gpxe_assert $edx 0xedaabbcc "gpxe_test_regs_write edx"
- gpxe_assert $esi 0x51ddeeff "gpxe_test_regs_write esi"
- gpxe_assert $edi 0xd1010203 "gpxe_test_regs_write edi"
-
- # This assumes segment selectors are always 0x10 or 0x8 (for code).
- gpxe_assert $cs 0x08 "gpxe_test_regs_write cs"
- gpxe_assert $ds 0x10 "gpxe_test_regs_write ds"
-end
-
-define gpxe_test_mem_read
- c
- gpxe_assert ({int}($esp+4)) 0x11223344 "gpxe_test_mem_read int"
- gpxe_assert ({short}($esp+2)) 0x5566 "gpxe_test_mem_read short"
- gpxe_assert ({char}($esp)) 0x77 "gpxe_test_mem_read char"
-end
-
-define gpxe_test_mem_write
- set ({int}($esp+4)) = 0xaabbccdd
- set ({short}($esp+2)) = 0xeeff
- set ({char}($esp)) = 0x99
- c
- gpxe_assert ({int}($esp+4)) 0xaabbccdd "gpxe_test_mem_write int"
- gpxe_assert ({short}($esp+2)) (short)0xeeff "gpxe_test_mem_write short"
- gpxe_assert ({char}($esp)) (char)0x99 "gpxe_test_mem_write char"
-end
-
-define gpxe_test_step
- c
- si
- gpxe_assert ({char}($eip-1)) (char)0x90 "gpxe_test_step" # nop = 0x90
-end
-
-define gpxe_test_awatch
- awatch watch_me
-
- c
- gpxe_assert $ecx 0x600d0000 "gpxe_test_awatch read"
- if $ecx == 0x600d0000
- c
- end
-
- c
- gpxe_assert $ecx 0x600d0001 "gpxe_test_awatch write"
- if $ecx == 0x600d0001
- c
- end
-
- delete
-end
-
-define gpxe_test_watch
- watch watch_me
- c
- gpxe_assert $ecx 0x600d0002 "gpxe_test_watch"
- if $ecx == 0x600d0002
- c
- end
- delete
-end
-
-gpxe_load_symbols
-gpxe_start_tests
-gpxe_test_regs_read
-gpxe_test_regs_write
-gpxe_test_mem_read
-gpxe_test_mem_write
-gpxe_test_step
-gpxe_test_awatch
-gpxe_test_watch
diff --git a/gpxe/src/tests/linebuf_test.c b/gpxe/src/tests/linebuf_test.c
deleted file mode 100644
index c3c3b375..00000000
--- a/gpxe/src/tests/linebuf_test.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <gpxe/linebuf.h>
-
-static const char data1[] =
-"Hello world\r\n"
-"This is a reasonably nice set of lines\n"
-"with not many different terminators\r\n\r\n"
-"There should be exactly one blank line above\n"
-"and this line should never appear at all since it has no terminator";
-
-void linebuf_test ( void ) {
- struct line_buffer linebuf;
- const char *data = data1;
- size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ );
- ssize_t frag_len;
- char *line;
-
- memset ( &linebuf, 0, sizeof ( linebuf ) );
- while ( len ) {
- frag_len = line_buffer ( &linebuf, data, len );
- if ( frag_len < 0 ) {
- printf ( "line_buffer() failed: %s\n",
- strerror ( frag_len ) );
- return;
- }
- data += frag_len;
- len -= frag_len;
- if ( ( line = buffered_line ( &linebuf ) ) )
- printf ( "\"%s\"\n", line );
- }
-
- empty_line_buffer ( &linebuf );
-}
diff --git a/gpxe/src/tests/memcpy_test.c b/gpxe/src/tests/memcpy_test.c
deleted file mode 100644
index 7626e639..00000000
--- a/gpxe/src/tests/memcpy_test.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <string.h>
-
-/*
- * This file exists for testing the compilation of memcpy() with the
- * various constant-length optimisations.
- *
- */
-
-#define __regparm __attribute__ (( regparm(3) ))
-
-void __regparm memcpy_0 ( void *dest, void *src ) { memcpy ( dest, src, 0 ); }
-void __regparm memcpy_1 ( void *dest, void *src ) { memcpy ( dest, src, 1 ); }
-void __regparm memcpy_2 ( void *dest, void *src ) { memcpy ( dest, src, 2 ); }
-void __regparm memcpy_3 ( void *dest, void *src ) { memcpy ( dest, src, 3 ); }
-void __regparm memcpy_4 ( void *dest, void *src ) { memcpy ( dest, src, 4 ); }
-void __regparm memcpy_5 ( void *dest, void *src ) { memcpy ( dest, src, 5 ); }
-void __regparm memcpy_6 ( void *dest, void *src ) { memcpy ( dest, src, 6 ); }
-void __regparm memcpy_7 ( void *dest, void *src ) { memcpy ( dest, src, 7 ); }
-void __regparm memcpy_8 ( void *dest, void *src ) { memcpy ( dest, src, 8 ); }
-void __regparm memcpy_9 ( void *dest, void *src ) { memcpy ( dest, src, 9 ); }
-void __regparm memcpy_10 ( void *dest, void *src ) { memcpy ( dest, src, 10 ); }
-void __regparm memcpy_11 ( void *dest, void *src ) { memcpy ( dest, src, 11 ); }
-void __regparm memcpy_12 ( void *dest, void *src ) { memcpy ( dest, src, 12 ); }
-void __regparm memcpy_13 ( void *dest, void *src ) { memcpy ( dest, src, 13 ); }
-void __regparm memcpy_14 ( void *dest, void *src ) { memcpy ( dest, src, 14 ); }
-void __regparm memcpy_15 ( void *dest, void *src ) { memcpy ( dest, src, 15 ); }
-void __regparm memcpy_16 ( void *dest, void *src ) { memcpy ( dest, src, 16 ); }
-void __regparm memcpy_17 ( void *dest, void *src ) { memcpy ( dest, src, 17 ); }
-void __regparm memcpy_18 ( void *dest, void *src ) { memcpy ( dest, src, 18 ); }
-void __regparm memcpy_19 ( void *dest, void *src ) { memcpy ( dest, src, 19 ); }
-void __regparm memcpy_20 ( void *dest, void *src ) { memcpy ( dest, src, 20 ); }
-void __regparm memcpy_21 ( void *dest, void *src ) { memcpy ( dest, src, 21 ); }
-void __regparm memcpy_22 ( void *dest, void *src ) { memcpy ( dest, src, 22 ); }
-void __regparm memcpy_23 ( void *dest, void *src ) { memcpy ( dest, src, 23 ); }
-void __regparm memcpy_24 ( void *dest, void *src ) { memcpy ( dest, src, 24 ); }
-void __regparm memcpy_25 ( void *dest, void *src ) { memcpy ( dest, src, 25 ); }
-void __regparm memcpy_26 ( void *dest, void *src ) { memcpy ( dest, src, 26 ); }
-void __regparm memcpy_27 ( void *dest, void *src ) { memcpy ( dest, src, 27 ); }
-void __regparm memcpy_28 ( void *dest, void *src ) { memcpy ( dest, src, 28 ); }
diff --git a/gpxe/src/tests/umalloc_test.c b/gpxe/src/tests/umalloc_test.c
deleted file mode 100644
index 7a361868..00000000
--- a/gpxe/src/tests/umalloc_test.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <stdio.h>
-#include <gpxe/uaccess.h>
-#include <gpxe/umalloc.h>
-#include <gpxe/memmap.h>
-
-void umalloc_test ( void ) {
- struct memory_map memmap;
- userptr_t bob;
- userptr_t fred;
-
- printf ( "Before allocation:\n" );
- get_memmap ( &memmap );
-
- bob = umalloc ( 1234 );
- bob = urealloc ( bob, 12345 );
- fred = umalloc ( 999 );
-
- printf ( "After allocation:\n" );
- get_memmap ( &memmap );
-
- ufree ( bob );
- ufree ( fred );
-
- printf ( "After freeing:\n" );
- get_memmap ( &memmap );
-}
diff --git a/gpxe/src/tests/uri_test.c b/gpxe/src/tests/uri_test.c
deleted file mode 100644
index ca3aed9f..00000000
--- a/gpxe/src/tests/uri_test.c
+++ /dev/null
@@ -1,148 +0,0 @@
-#include <stdint.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <gpxe/uri.h>
-
-#define URI_MAX_LEN 1024
-
-struct uri_test {
- const char *base_uri_string;
- const char *relative_uri_string;
- const char *resolved_uri_string;
-};
-
-static struct uri_test uri_tests[] = {
- { "http://www.fensystems.co.uk", "",
- "http://www.fensystems.co.uk/" },
- { "http://etherboot.org/wiki/page1", "page2",
- "http://etherboot.org/wiki/page2" },
- { "http://etherboot.org/wiki/page1", "../page3",
- "http://etherboot.org/page3" },
- { "tftp://192.168.0.1/", "/tftpboot/vmlinuz",
- "tftp://192.168.0.1/tftpboot/vmlinuz" },
- { "ftp://the%41nswer%3d:%34ty%32wo@ether%62oot.org:8080/p%41th/foo",
- "to?%41=b#%43d",
- "ftp://theAnswer%3d:4ty2wo@etherboot.org:8080/path/to?a=b#cd" },
-#if 0
- "http://www.etherboot.org/wiki",
- "mailto:bob@nowhere.com",
- "ftp://joe:secret@insecure.org:8081/hidden/path/to?what=is#this",
-#endif
-};
-
-static int test_parse_unparse ( const char *uri_string ) {
- char buf[URI_MAX_LEN];
- size_t len;
- struct uri *uri = NULL;
- int rc;
-
- /* Parse and unparse URI */
- uri = parse_uri ( uri_string );
- if ( ! uri ) {
- rc = -ENOMEM;
- goto done;
- }
- len = unparse_uri ( buf, sizeof ( buf ), uri, URI_ALL );
-
- /* Compare result */
- if ( strcmp ( buf, uri_string ) != 0 ) {
- printf ( "Unparse of \"%s\" produced \"%s\"\n",
- uri_string, buf );
- rc = -EINVAL;
- goto done;
- }
-
- rc = 0;
-
- done:
- uri_put ( uri );
- if ( rc ) {
- printf ( "URI parse-unparse of \"%s\" failed: %s\n",
- uri_string, strerror ( rc ) );
- }
- return rc;
-}
-
-static int test_resolve ( const char *base_uri_string,
- const char *relative_uri_string,
- const char *resolved_uri_string ) {
- struct uri *base_uri = NULL;
- struct uri *relative_uri = NULL;
- struct uri *resolved_uri = NULL;
- char buf[URI_MAX_LEN];
- size_t len;
- int rc;
-
- /* Parse URIs */
- base_uri = parse_uri ( base_uri_string );
- if ( ! base_uri ) {
- rc = -ENOMEM;
- goto done;
- }
- relative_uri = parse_uri ( relative_uri_string );
- if ( ! relative_uri ) {
- rc = -ENOMEM;
- goto done;
- }
-
- /* Resolve URI */
- resolved_uri = resolve_uri ( base_uri, relative_uri );
- if ( ! resolved_uri ) {
- rc = -ENOMEM;
- goto done;
- }
-
- /* Compare result */
- len = unparse_uri ( buf, sizeof ( buf ), resolved_uri, URI_ALL );
- if ( strcmp ( buf, resolved_uri_string ) != 0 ) {
- printf ( "Resolution of \"%s\"+\"%s\" produced \"%s\"\n",
- base_uri_string, relative_uri_string, buf );
- rc = -EINVAL;
- goto done;
- }
-
- rc = 0;
-
- done:
- uri_put ( base_uri );
- uri_put ( relative_uri );
- uri_put ( resolved_uri );
- if ( rc ) {
- printf ( "URI resolution of \"%s\"+\"%s\" failed: %s\n",
- base_uri_string, relative_uri_string,
- strerror ( rc ) );
- }
- return rc;
-}
-
-int uri_test ( void ) {
- unsigned int i;
- struct uri_test *uri_test;
- int rc;
- int overall_rc = 0;
-
- for ( i = 0 ; i < ( sizeof ( uri_tests ) /
- sizeof ( uri_tests[0] ) ) ; i++ ) {
- uri_test = &uri_tests[i];
- rc = test_parse_unparse ( uri_test->base_uri_string );
- if ( rc != 0 )
- overall_rc = rc;
- rc = test_parse_unparse ( uri_test->relative_uri_string );
- if ( rc != 0 )
- overall_rc = rc;
- rc = test_parse_unparse ( uri_test->resolved_uri_string );
- if ( rc != 0 )
- overall_rc = rc;
- rc = test_resolve ( uri_test->base_uri_string,
- uri_test->relative_uri_string,
- uri_test->resolved_uri_string );
- if ( rc != 0 )
- overall_rc = rc;
- }
-
- if ( overall_rc )
- printf ( "URI tests failed: %s\n", strerror ( overall_rc ) );
- return overall_rc;
-}