From 93639abfdcf4458f00278e2945266e2f406745a0 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 8 Oct 2021 20:57:31 +0200 Subject: [PATCH] Import a first helper for tests --- project.conf | 2 +- tests/arch/amd64/printself.S | 42 +++++++++++++++++++++++++++++++++++ tests/arch/amd64/project.conf | 1 + tests/printself.S | 37 ++++++++++++++++++++++++++++++ tests/project.conf | 25 +++++++++++++++++++++ 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 tests/arch/amd64/printself.S create mode 100644 tests/arch/amd64/project.conf create mode 100644 tests/printself.S create mode 100644 tests/project.conf diff --git a/project.conf b/project.conf index 60a9bbe..872badb 100644 --- a/project.conf +++ b/project.conf @@ -1,5 +1,5 @@ package=Loader version=0.0.0 -subdirs=src,tools +subdirs=src,tests,tools dist=Makefile,COPYING diff --git a/tests/arch/amd64/printself.S b/tests/arch/amd64/printself.S new file mode 100644 index 0000000..f9aea66 --- /dev/null +++ b/tests/arch/amd64/printself.S @@ -0,0 +1,42 @@ +/* $Id$ */ +/* Copyright (c) 2021 Pierre Pronchery */ +/* This file is part of DeforaOS System Loader */ +/* All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + + + +/* main */ +.text +.global main +.type main,@function +main: + /* puts(argv[0]) */ + mov (%rsi), %rdi + call puts + + /* return 0x42 */ + mov $0x42, %rax + ret diff --git a/tests/arch/amd64/project.conf b/tests/arch/amd64/project.conf new file mode 100644 index 0000000..af3cb93 --- /dev/null +++ b/tests/arch/amd64/project.conf @@ -0,0 +1 @@ +dist=Makefile,printself.S diff --git a/tests/printself.S b/tests/printself.S new file mode 100644 index 0000000..fd43f12 --- /dev/null +++ b/tests/printself.S @@ -0,0 +1,37 @@ +/* $Id$ */ +/* Copyright (c) 2021 Pierre Pronchery */ +/* This file is part of DeforaOS System Loader */ +/* All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + + + +/* amd64 */ +#if defined(__amd64__) +# include "arch/amd64/printself.S" + +#else +# error "Unsupported platform" +#endif diff --git a/tests/project.conf b/tests/project.conf new file mode 100644 index 0000000..316268e --- /dev/null +++ b/tests/project.conf @@ -0,0 +1,25 @@ +subdirs=arch/amd64 +targets=printself +as=$(CC) +asflags_force=$(CPPFLAGSF) $(CFLAGSF) -c +asflags=$(CPPFLAGS) $(CFLAGS) +cppflags_force= +cflags_force=-g +cflags=-W -Wall -O2 -D_FORTIFY_SOURCE=2 -fstack-protector +dist=Makefile +mode=amd64-debug + +#modes +[mode::amd64-release] +cppflags_force=-DNDEBUG +cflags_force= + +[mode::i386-release] +cppflags_force=-DNDEBUG +cflags_force= + +#targets +[printself] +type=binary +ldflags=-static +sources=printself.S