test: Build initial scaffold tests without libc.
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 15 Aug 2018 15:47:03 +0000 (17:47 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 15 Aug 2018 15:47:03 +0000 (17:47 +0200)
* scaffold/argv.c (strcmp): New function; support building without
libc.
* build-aux/build-cc.sh: Build initial scaffold tests without libc.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* scaffold/read.data: Rename from `mesmes'.
* scaffold/read.c: Rename from `m.c'; update.

build-aux/build-cc.sh
build-aux/build-cc32.sh
build-aux/build-mes.sh
build-aux/check-mescc.sh
scaffold/argv.c
scaffold/m.c [deleted file]
scaffold/mesmes [deleted file]
scaffold/read.c [new file with mode: 0644]
scaffold/read.data [new file with mode: 0644]

index 6852d0507818733846f5052e68e444c6cee6f012..02ca47ab710a1ffed839e8a457751f8a5e57bfa4 100755 (executable)
@@ -59,9 +59,10 @@ ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libtcc1
 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libc+gnu
 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libg
 
-sh ${srcdest}build-aux/cc64-mes.sh scaffold/main
-sh ${srcdest}build-aux/cc64-mes.sh scaffold/hello
-sh ${srcdest}build-aux/cc64-mes.sh scaffold/argv
+LIBC= sh ${srcdest}build-aux/cc64-mes.sh scaffold/main
+LIBC=c-mini sh ${srcdest}build-aux/cc64-mes.sh scaffold/hello
+LIBC=c-mini sh ${srcdest}build-aux/cc64-mes.sh scaffold/argv
+sh ${srcdest}build-aux/cc64-mes.sh scaffold/read
 sh ${srcdest}build-aux/cc64-mes.sh scaffold/malloc
 sh ${srcdest}build-aux/cc64-mes.sh scaffold/micro-mes
 sh ${srcdest}build-aux/cc64-mes.sh scaffold/tiny-mes
index 2a5b35b815d73abeb12ebba283897374508f5d69..404afe6e126cc374932cfa44092e3392eef32685 100755 (executable)
@@ -57,9 +57,10 @@ ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libtcc1
 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libc+gnu
 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libg
 
-sh ${srcdest}build-aux/cc32-mes.sh scaffold/main
-sh ${srcdest}build-aux/cc32-mes.sh scaffold/hello
-sh ${srcdest}build-aux/cc32-mes.sh scaffold/argv
+LIBC= sh ${srcdest}build-aux/cc32-mes.sh scaffold/main
+LIBC=c-mini sh ${srcdest}build-aux/cc32-mes.sh scaffold/hello
+LIBC=c-mini sh ${srcdest}build-aux/cc32-mes.sh scaffold/argv
+sh ${srcdest}build-aux/cc32-mes.sh scaffold/read
 sh ${srcdest}build-aux/cc32-mes.sh scaffold/malloc
 sh ${srcdest}build-aux/cc32-mes.sh scaffold/micro-mes
 sh ${srcdest}build-aux/cc32-mes.sh scaffold/tiny-mes
index 35a75699442397dd40d7556dd377c86e434f4710..4882dac1ae8e425a8b5c10566aea7614fbd23926 100755 (executable)
@@ -116,8 +116,7 @@ fi
 MES_ARENA=100000000
 ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crt1
 ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc-mini
-
-PREPROCESS= bash ${srcdest}build-aux/cc-mes.sh lib/x86-mes/exit-42
+MES_LIBS='-l c-mini' PREPROCESS= bash ${srcdest}build-aux/cc-mes.sh lib/x86-mes/exit-42
 
 trace "TEST       lib/x86-mes/exit-42.mes-out" echo lib/x86-mes/exit-42.mes-out
 { set +e; lib/x86-mes/exit-42.mes-out; r=$?; set -e; }
@@ -147,9 +146,14 @@ trace "SNARF.mes  vector.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.sc
 echo MES_ARENA=$MES_ARENA
 bash ${srcdest}build-aux/cc-mes.sh scaffold/main
 
-bash ${srcdest}build-aux/cc-mes.sh scaffold/main
-bash ${srcdest}build-aux/cc-mes.sh scaffold/hello
-bash ${srcdest}build-aux/cc-mes.sh scaffold/argv
+MES_LIBS='-l none' bash ${srcdest}build-aux/cc-mes.sh scaffold/main
+
+trace "TEST       scaffold/main.mes-out" echo scaffold/main.mes-out
+{ set +e; scaffold/main.mes-out; r=$?; set -e; }
+[ $r != 42 ] && echo "  => $r" && exit 1
+
+MES_LIBS='-l c-mini' bash ${srcdest}build-aux/cc-mes.sh scaffold/hello
+MES_LIBS='-l c-mini' bash ${srcdest}build-aux/cc-mes.sh scaffold/argv
 bash ${srcdest}build-aux/cc-mes.sh scaffold/malloc
 ##sh ${srcdest}build-aux/cc-mes.sh scaffold/micro-mes
 ##sh ${srcdest}build-aux/cc-mes.sh scaffold/tiny-mes
index ff04eae0940cf0d7d30361ca9cae974b4f135f3b..b79dc8f15bc30c3129c023448478ecf0a9351fd6 100755 (executable)
@@ -154,7 +154,10 @@ fail=0
 total=0
 mkdir -p scaffold/tests
 for t in $tests; do
-    if [ -z "${t/[012][0-9]-*/}" ]; then
+    if [ -z "${t/[01][0-9]-*/}" ]; then
+        LIBC=
+        MES_LIBS="-l none"
+    elif [ -z "${t/[2][0-9]-*/}" ]; then
         LIBC=c-mini
         MES_LIBS="-l c-mini"
     elif [ -z "${t/[78][0-9a-z]-*/}" ]; then
index 7debb05bbe1274ccafd75e9d19e7d9f18d9bb5fb..3abee39c4058b5d71cee7e24fec1e3a85f4dfdc7 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-comment-start: "//";comment-end:""-*-
  * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+ * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  *
  * This file is part of GNU Mes.
  *
 #include <libmes.h>
 #include <string.h>
 
+int
+strcmp (char const* a, char const* b)
+{
+  while (*a && *b && *a == *b)
+    {
+      a++;
+      b++;
+    }
+  return *a - *b;
+}
+
 int
 main (int argc, char *argv[])
 {
diff --git a/scaffold/m.c b/scaffold/m.c
deleted file mode 100644 (file)
index a7a58ea..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*-comment-start: "//";comment-end:""-*-
- * GNU Mes --- Maxwell Equations of Software
- * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
- *
- * This file is part of GNU Mes.
- *
- * GNU Mes is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at
- * your option) any later version.
- *
- * GNU Mes is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main (int argc, char *argv[])
-{
-  g_stdin = open ("scaffold/mesmes", 0);
-  int c = getchar ();
-  if (c != 'm') return c;
-  while (c != EOF) {
-    putchar (c);
-    c = getchar ();
-  }
-  return c;
-}
diff --git a/scaffold/mesmes b/scaffold/mesmes
deleted file mode 100644 (file)
index 037bc16..0000000
+++ /dev/null
@@ -1 +0,0 @@
-mesmes
diff --git a/scaffold/read.c b/scaffold/read.c
new file mode 100644 (file)
index 0000000..c58f8aa
--- /dev/null
@@ -0,0 +1,36 @@
+/* -*-comment-start: "//";comment-end:""-*-
+ * GNU Mes --- Maxwell Equations of Software
+ * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+ *
+ * This file is part of GNU Mes.
+ *
+ * GNU Mes is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * GNU Mes is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Mes.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char *argv[])
+{
+  g_stdin = open ("scaffold/read.data", 0);
+  int c = getchar ();
+  if (c != 'm')
+    return 1;
+  while (c != EOF) {
+    putchar (c);
+    c = getchar ();
+  }
+}
diff --git a/scaffold/read.data b/scaffold/read.data
new file mode 100644 (file)
index 0000000..037bc16
--- /dev/null
@@ -0,0 +1 @@
+mesmes