summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-29 22:24:35 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-29 22:24:35 +0000
commit14b929f1d90af2604c51670eed840b894d2d9b87 (patch)
tree609477a446532ee38b6ca750e1a1e562575e8a0b
parent62ad189a65e5e3b4cb6c64c9ea2d493f2c06fffd (diff)
parent242856cfbf2a70838bf0daf267eb7af7bf78bb3b (diff)
downloadmicropython-14b929f1d90af2604c51670eed840b894d2d9b87.tar.gz
micropython-14b929f1d90af2604c51670eed840b894d2d9b87.zip
Merge branch 'master' of github.com:msiemens/micropython into msiemens-master
-rw-r--r--py/asmx64.c1
-rw-r--r--py/nlrx86.S29
-rwxr-xr-xtests/run-tests106
-rw-r--r--windows/Makefile36
-rw-r--r--windows/file.c2
-rw-r--r--windows/main.c5
-rw-r--r--windows/mpconfigport.h36
-rw-r--r--windows/qstrdefsport.h8
8 files changed, 167 insertions, 56 deletions
diff --git a/py/asmx64.c b/py/asmx64.c
index d3158170fb..de34332481 100644
--- a/py/asmx64.c
+++ b/py/asmx64.c
@@ -1,3 +1,4 @@
+#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
diff --git a/py/nlrx86.S b/py/nlrx86.S
index 3e2eec7a7b..5cfd4a8cfc 100644
--- a/py/nlrx86.S
+++ b/py/nlrx86.S
@@ -5,9 +5,15 @@
.text
/* uint nlr_push(4(%esp)=nlr_buf_t *nlr) */
+#ifdef _WIN32
+ .globl _nlr_push
+ .def _nlr_push; .scl 2; .type 32; .endef
+_nlr_push:
+#else
.globl nlr_push
.type nlr_push, @function
nlr_push:
+#endif
mov 4(%esp), %edx # load nlr_buf
mov (%esp), %eax # load return %ip
mov %eax, 8(%edx) # store %ip into nlr_buf+8
@@ -21,22 +27,38 @@ nlr_push:
mov %edx, nlr_top # stor new nlr_buf (to make linked list)
xor %eax, %eax # return 0, normal return
ret # return
+#ifndef _WIN32
.size nlr_push, .-nlr_push
+#endif
/* void nlr_pop() */
+#ifdef _WIN32
+ .globl _nlr_pop
+ .def _nlr_pop; .scl 2; .type 32; .endef
+_nlr_pop:
+#else
.globl nlr_pop
.type nlr_pop, @function
nlr_pop:
+#endif
mov nlr_top, %eax # load nlr_top
mov (%eax), %eax # load prev nlr_buf
mov %eax, nlr_top # store nlr_top (to unlink list)
ret # return
+#ifndef _WIN32
.size nlr_pop, .-nlr_pop
+#endif
/* void nlr_jump(4(%esp)=uint val) */
+#ifdef _WIN32
+ .globl _nlr_jump
+ .def _nlr_jump; .scl 2; .type 32; .endef
+_nlr_jump:
+#else
.globl nlr_jump
.type nlr_jump, @function
nlr_jump:
+#endif
mov nlr_top, %edx # load nlr_top
mov 4(%esp), %eax # load return value
mov %eax, 4(%edx) # store return value
@@ -52,8 +74,13 @@ nlr_jump:
xor %eax, %eax # clear return register
inc %al # increase to make 1, non-local return
ret # return
+#ifndef _WIN32
.size nlr_jump, .-nlr_jump
+#endif
+#ifndef _WIN32
.local nlr_top
- .comm nlr_top,4,4
#endif
+ .comm nlr_top,4,4
+
+#endif /* __i386__ */
diff --git a/tests/run-tests b/tests/run-tests
index 752138ccc6..ed5a3b20ae 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -1,55 +1,51 @@
-#!/usr/bin/env bash
-
-RM="/bin/rm -f"
-CPYTHON3=python3.3
-MP_PY=../unix/micropython
-
-numtests=0
-numtestcases=0
-numpassed=0
-numfailed=0
-namefailed=
-
-if [ $# -eq 0 ]
-then
- tests="basics/*.py io/*.py"
-else
- tests="$@"
-fi
-
-for infile in $tests
-do
- basename=`basename $infile .py`
- outfile=${basename}.out
- expfile=${basename}.exp
-
- $CPYTHON3 -B $infile > $expfile
- $MP_PY $infile > $outfile
- ((numtestcases = numtestcases + $(cat $expfile | wc -l)))
-
- diff --brief $expfile $outfile > /dev/null
-
- if [ $? -eq 0 ]
- then
- echo "pass $infile"
- $RM $outfile
- $RM $expfile
- ((numpassed=numpassed + 1))
- else
- echo "FAIL $infile"
- ((numfailed=numfailed + 1))
- namefailed="$namefailed $basename"
- fi
-
- ((numtests=numtests + 1))
-done
-
-echo "$numtests tests performed ($numtestcases individual testcases)"
-echo "$numpassed tests passed"
-if [[ $numfailed != 0 ]]
-then
- echo "$numfailed tests failed -$namefailed"
- exit 1
-else
- exit 0
-fi
+#! /usr/bin/env python3.3
+
+import os
+import subprocess
+import sys
+from glob import glob
+
+if os.name == 'nt':
+ CPYTHON3 = 'python3.3.exe'
+ MP_PY = '../windows/micropython.exe'
+else:
+ CPYTHON3 = 'python3.3'
+ MP_PY = '../unix/micropython'
+
+
+test_count = 0
+testcase_count = 0
+passed_count = 0
+failed_tests = []
+tests = []
+
+if not sys.argv[1:]:
+ tests = glob('basics/*.py') + glob('io/*.py')
+else:
+ tests = sys.argv[1:]
+
+for test_file in tests:
+ test_name = os.path.splitext(os.path.basename(test_file))[0]
+
+ output_expected = subprocess.check_output([CPYTHON3, '-B', test_file])
+ output_mypy = subprocess.check_output([MP_PY, test_file])
+
+ testcase_count += len(output_expected.splitlines())
+
+ if output_expected != output_mypy:
+ print("pass ", test_file)
+ passed_count += 1
+ else:
+ print("FAIL ", test_file)
+ failed_tests.append(test_name)
+
+ test_count += 1
+
+print("{} tests performed ({} individual testcases)".format(test_count,
+ testcase_count))
+print("{} tests passed".format(passed_count))
+
+if len(failed_tests) > 0:
+ print("{} tests failed: {}".format(len(failed_tests),
+ ' '.join(failed_tests)))
+ sys.exit(1)
diff --git a/windows/Makefile b/windows/Makefile
new file mode 100644
index 0000000000..a9a39a620e
--- /dev/null
+++ b/windows/Makefile
@@ -0,0 +1,36 @@
+include ../py/mkenv.mk
+
+# define main target
+PROG = micropython.exe
+
+# qstr definitions (must come before including py.mk)
+QSTR_DEFS = qstrdefsport.h
+
+# include py core make definitions
+include ../py/py.mk
+
+# compiler settings
+CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX
+LDFLAGS = -lm
+
+# Debugging/Optimization
+ifdef DEBUG
+CFLAGS += -O0 -g
+else
+CFLAGS += -Os #-DNDEBUG
+endif
+
+# source files
+SRC_C = \
+ main.c \
+ file.c \
+
+OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
+LIB = -lreadline
+LIB += -lws2_32
+LIB += -lmman
+# the following is needed for BSD
+#LIB += -ltermcap
+
+include ../py/mkrules.mk
+
diff --git a/windows/file.c b/windows/file.c
new file mode 100644
index 0000000000..2651ffafb6
--- /dev/null
+++ b/windows/file.c
@@ -0,0 +1,2 @@
+#include <stdio.h>
+#include "../unix/file.c" \ No newline at end of file
diff --git a/windows/main.c b/windows/main.c
new file mode 100644
index 0000000000..64e34fa354
--- /dev/null
+++ b/windows/main.c
@@ -0,0 +1,5 @@
+#include "../unix/main.c"
+
+void rawsocket_init() {
+ // Do nothing here
+} \ No newline at end of file
diff --git a/windows/mpconfigport.h b/windows/mpconfigport.h
new file mode 100644
index 0000000000..10abb8ce75
--- /dev/null
+++ b/windows/mpconfigport.h
@@ -0,0 +1,36 @@
+// options to control how Micro Python is built
+
+// Linking with GNU readline causes binary to be licensed under GPL
+#ifndef MICROPY_USE_READLINE
+#define MICROPY_USE_READLINE (1)
+#endif
+
+#define MICROPY_EMIT_X64 (1)
+#define MICROPY_EMIT_THUMB (0)
+#define MICROPY_EMIT_INLINE_THUMB (0)
+#define MICROPY_MEM_STATS (1)
+#define MICROPY_DEBUG_PRINTERS (1)
+#define MICROPY_ENABLE_REPL_HELPERS (1)
+#define MICROPY_ENABLE_LEXER_UNIX (1)
+#define MICROPY_ENABLE_FLOAT (1)
+#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
+
+// type definitions for the specific machine
+
+#ifdef __LP64__
+typedef long machine_int_t; // must be pointer size
+typedef unsigned long machine_uint_t; // must be pointer size
+#else
+// These are definitions for machines where sizeof(int) == sizeof(void*),
+// regardless for actual size.
+typedef int machine_int_t; // must be pointer size
+typedef unsigned int machine_uint_t; // must be pointer size
+#endif
+
+#define BYTES_PER_WORD sizeof(machine_int_t)
+
+typedef void *machine_ptr_t; // must be of pointer size
+typedef const void *machine_const_ptr_t; // must be of pointer size
+typedef double machine_float_t;
+
+machine_float_t machine_sqrt(machine_float_t x);
diff --git a/windows/qstrdefsport.h b/windows/qstrdefsport.h
new file mode 100644
index 0000000000..8a4c47f0b5
--- /dev/null
+++ b/windows/qstrdefsport.h
@@ -0,0 +1,8 @@
+// qstrs specific to this port
+
+Q(sys)
+Q(argv)
+Q(open)
+Q(stdin)
+Q(stdout)
+Q(stderr) \ No newline at end of file