Permalink
Browse files

TESTS: Use std libs for lib-test.reds, remove previous pre-compiled l…

…ib tests
  • Loading branch information...
1 parent d8ff07a commit c215564c6ee086a787c09b818c8c43157a2b344c @PeterWAWood PeterWAWood committed Apr 14, 2012
Showing with 182 additions and 660 deletions.
  1. +3 −55 red-system/tests/run-all.r
  2. +24 −0 red-system/tests/source/units/lib-osx-test.reds
  3. +0 −96 red-system/tests/source/units/lib-test-source.reds
  4. +121 −0 red-system/tests/source/units/lib-test.reds
  5. +34 −0 red-system/tests/source/units/lib-win32-test.reds
  6. BIN red-system/tests/source/units/libs/f32testlib1.dll
  7. +0 −45 red-system/tests/source/units/libs/f32testlib1.pas
  8. BIN red-system/tests/source/units/libs/f32testlib2.dll
  9. +0 −38 red-system/tests/source/units/libs/f32testlib2.pas
  10. BIN red-system/tests/source/units/libs/f32testlib3.dll
  11. +0 −38 red-system/tests/source/units/libs/f32testlib3.pas
  12. BIN red-system/tests/source/units/libs/ftestlib1.dll
  13. +0 −45 red-system/tests/source/units/libs/ftestlib1.pas
  14. BIN red-system/tests/source/units/libs/ftestlib2.dll
  15. +0 −38 red-system/tests/source/units/libs/ftestlib2.pas
  16. BIN red-system/tests/source/units/libs/ftestlib3.dll
  17. +0 −38 red-system/tests/source/units/libs/ftestlib3.pas
  18. BIN red-system/tests/source/units/libs/libf32testlib1.dylib
  19. BIN red-system/tests/source/units/libs/libf32testlib1.so
  20. BIN red-system/tests/source/units/libs/libf32testlib2.dylib
  21. BIN red-system/tests/source/units/libs/libf32testlib2.so
  22. BIN red-system/tests/source/units/libs/libf32testlib3.dylib
  23. BIN red-system/tests/source/units/libs/libf32testlib3.so
  24. BIN red-system/tests/source/units/libs/libftestlib1.dylib
  25. BIN red-system/tests/source/units/libs/libftestlib1.so
  26. BIN red-system/tests/source/units/libs/libftestlib2.dylib
  27. BIN red-system/tests/source/units/libs/libftestlib2.so
  28. BIN red-system/tests/source/units/libs/libftestlib3.dylib
  29. BIN red-system/tests/source/units/libs/libftestlib3.so
  30. BIN red-system/tests/source/units/libs/libtestlib1.dylib
  31. BIN red-system/tests/source/units/libs/libtestlib1.so
  32. BIN red-system/tests/source/units/libs/libtestlib2.dylib
  33. BIN red-system/tests/source/units/libs/libtestlib2.so
  34. BIN red-system/tests/source/units/libs/libtestlib3.dylib
  35. BIN red-system/tests/source/units/libs/libtestlib3.so
  36. BIN red-system/tests/source/units/libs/libtestlib4.dylib
  37. BIN red-system/tests/source/units/libs/libtestlib4.so
  38. BIN red-system/tests/source/units/libs/testlib1.dll
  39. +0 −45 red-system/tests/source/units/libs/testlib1.pas
  40. BIN red-system/tests/source/units/libs/testlib2.dll
  41. +0 −38 red-system/tests/source/units/libs/testlib2.pas
  42. BIN red-system/tests/source/units/libs/testlib3.dll
  43. +0 −38 red-system/tests/source/units/libs/testlib3.pas
  44. BIN red-system/tests/source/units/libs/testlib4.dll
  45. +0 −44 red-system/tests/source/units/libs/testlib4.pas
  46. +0 −51 red-system/tests/source/units/make-float-lib-auto-test.r
  47. +0 −51 red-system/tests/source/units/make-lib-auto-test.r
View
@@ -2,7 +2,7 @@ REBOL [
Title: "Builds and Runs the Red/System Tests"
File: %run-all.r
Author: "Peter W A Wood"
- Version: 0.8.0
+ Version: 0.8.1
License: "BSD-3 - https://github.com/dockimbel/Red/blob/master/BSD-3-License.txt"
]
@@ -64,55 +64,6 @@ make-if-needed? %source/units/auto-tests/float-auto-test.reds
make-if-needed? %source/units/auto-tests/float32-auto-test.reds
%source/units/make-float32-auto-test.r
-;; make lib-test files if needed
-lib-test-len: length? read %source/units/lib-test-source.reds
-save-len: either exists? %source/units/len-lib-test.dat [
- load %source/units/len-lib-test.dat
-][
- -1
-]
-
-if any [
- not exists? %source/units/auto-tests/lib-auto-test.reds
- lib-test-len <> save-len
-][
- save %source/units/len-lib-test.dat lib-test-len
- print "Making lib-test-auto.reds - shouldn't take long"
- do %source/units/make-lib-auto-test.r
-]
-
-flib-test-len: length? read %source/units/float-lib-test-source.reds
-save-len: either exists? %source/units/len-flib-test.dat [
- load %source/units/len-flib-test.dat
-][
- -1
-]
-
-f32lib-test-len: length? read %source/units/float32-lib-test-source.reds
-f32-save-len: either exists? %source/units/len-f32lib-test.dat [
- load %source/units/len-f32lib-test.dat
-][
- -1
-]
-
-if any [
- not exists? %source/units/auto-tests/float-lib-auto-test.reds
- flib-test-len <> save-len
-][
- save %source/units/len-flib-test.dat flib-test-len
- print "Making float-lib-test-auto.reds - shouldn't take long"
- do %source/units/make-float-lib-auto-test.r
-]
-
-if any [
- not exists? %source/units/auto-tests/float32-lib-auto-test.reds
- f32lib-test-len <> f32-save-len
-][
- save %source/units/len-f32lib-test.dat f32lib-test-len
- print "Making float32-lib-test-auto.reds - shouldn't take long"
- do %source/units/make-float32-lib-auto-test.r
-]
-
;; run the tests
print rejoin ["Run-All v" system/script/header/version]
print rejoin ["Quick-Test v" qt/version]
@@ -126,8 +77,7 @@ start-time: now/precise
***start-run-quiet*** "Red/System Test Suite"
===start-group=== "Datatype tests"
- --run-test-file-quiet %source/units/logic-test.reds
- ; --run-test-file-quiet %source/units/integer-test.reds ;; excluded from ARM tests
+ --run-test-file-quiet %source/units/logic-test.reds
--run-test-file-quiet %source/units/byte-test.reds
--run-test-file-quiet %source/units/c-string-test.reds
--run-test-file-quiet %source/units/struct-test.reds
@@ -139,6 +89,7 @@ start-time: now/precise
--run-test-file-quiet %source/units/enum-test.reds
--run-test-file-quiet %source/units/float-test.reds
--run-test-file-quiet %source/units/float32-test.reds
+ --run-test-file-quiet %source/units/lib-test.reds
===end-group===
===start-group=== "Native functions tests"
@@ -171,9 +122,6 @@ start-time: now/precise
--run-test-file-quiet %source/units/auto-tests/byte-auto-test.reds
--run-test-file-quiet %source/units/auto-tests/integer-auto-test.reds
--run-test-file-quiet %source/units/auto-tests/maths-auto-test.reds
- --run-test-file-quiet %source/units/auto-tests/lib-auto-test.reds ;; excluded from ARM tests
- --run-test-file-quiet %source/units/auto-tests/float-lib-auto-test.reds ; not in Arm tests
- --run-test-file-quiet %source/units/auto-tests/float32-lib-auto-test.reds ; not in Arm tests
--run-test-file-quiet %source/units/auto-tests/float-auto-test.reds
--run-test-file-quiet %source/units/auto-tests/float32-auto-test.reds
===end-group===
@@ -0,0 +1,24 @@
+Red/System [
+ Title: "Red/System lib osx test script"
+ Author: "Peter W A Wood"
+ File: %lib-test-source.reds
+ Rights: "Copyright (C) 2012 Peter W A Wood. All rights reserved."
+ License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
+]
+
+;; library declarations
+
+#import [
+ "/usr/lib/libsqlite3.dylib" cdecl [
+ sqlite3_libversion_number: "sqlite3_libversion_number" [
+ return: [integer!]
+ ]
+ ]
+]
+
+===start-group=== "OS X Core Foundation"
+
+ --test-- "libosx1"
+ --assert 0 < sqlite3_libversion_number
+
+===end-group===
@@ -1,96 +0,0 @@
-Red/System [
- Title: "Red/System lib test script"
- Author: "Peter W A Wood"
- File: %lib-test-source.reds
- Rights: "Copyright (C) 2011 Peter W A Wood. All rights reserved."
- License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
-]
-
-;; This script needs to be processed by make-lib-auto-test.r which sets the
-;; absolute path for the test libraries. It creates a file called
-;; lib-auto-test.reds in the auto-tests sub-directory. It also generates the
-;; correct name for the library under the os it is running
-
-#include %../../../../../quick-test/quick-test.reds
-
-;; library declarations
-#import [
- "***abs-path***###prefix###testlib1@@@extension@@@" cdecl [
- addone: "addone" [
- i [integer!]
- return: [integer!]
- ]
- subtractone: "subtractone" [
- i [integer!]
- return: [integer!]
- ]
- ]
-]
-
-#import [
- "***abs-path***###prefix###testlib2@@@extension@@@" cdecl [
- twice: "twice" [
- i [integer!]
- return: [integer!]
- ]
- ]
-]
-
-#import [
- "***abs-path***###prefix###testlib3@@@extension@@@" cdecl [
- halve: "halve" [
- i [integer!]
- return: [integer!]
- ]
- ]
-]
-
-#import [
- "***abs-path***###prefix###testlib4@@@extension@@@" cdecl [
- passitback: "passitback" [
- i [integer!]
- p-i-b [function! [
- i [integer!]
- return: [integer!]
- ]]
- return: [integer!]
- ]
- ]
-]
-
-
-~~~start-file~~~ "library"
-
-===start-group=== "calls"
- --test-- "lib1"
- --assert 2 = addone 1
- --assert 1 = subtractone 2
-
- --test-- "lib2"
- --assert 2 = twice 1
- --assert 4 = twice 2
-
- --test-- "lib3"
- --assert 1 = halve 2
- --assert 0 = halve 1
-===end-group===
-
-===start-group=== "callbacks"
- p-i-b: func [
- [cdecl]
- i [integer!]
- return: [integer!]
- ][
- i * 2
- ]
- --test-- "callback 1"
- --assert 2 = passitback 1 :p-i-b
- --test-- "callback 2"
- --assert 256 = passitback 128 :p-i-b
- --test-- "callback 3"
- --assert -2 = passitback -1 :p-i-b
-
-===end-group===
-
-~~~end-file~~~
-
@@ -0,0 +1,121 @@
+Red/System [
+ Title: "Red/System lib test script"
+ Author: "Peter W A Wood"
+ File: %lib-test-source.reds
+ Rights: "Copyright (C) 2012 Peter W A Wood. All rights reserved."
+ License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
+]
+
+#include %../../../../quick-test/quick-test.reds
+
+;; library declarations
+#import [
+ LIBM-file cdecl [
+ abs-float: "fabs" [
+ f [float!]
+ return: [float!]
+ ]
+ abs-int: "abs" [
+ i [integer!]
+ return: [integer!]
+ ]
+ ]
+]
+
+lt-array!: alias struct! [
+ a [integer!]
+ b [integer!]
+ c [integer!]
+ d [integer!]
+]
+
+lt-int!: alias struct! [
+ i [integer!]
+ ]
+#import [
+ LIBC-file cdecl [
+ memcpy: "memcpy" [
+ to [c-string!]
+ from [c-string!]
+ len [integer!]
+ ]
+ qsort: "qsort" [
+ array [lt-array!]
+ count [integer!]
+ size [integer!]
+ compare [function! [
+ first [lt-int!]
+ second [lt-int!]
+ return: [integer!]
+ ]]
+ ]
+ strnlen: "strnlen" [
+ str [c-string!]
+ maxlen [integer!]
+ return: [integer!]
+ ]
+ ]
+]
+
+~~~start-file~~~ "library"
+
+===start-group=== "calls"
+ --test-- "lib1"
+ --assert 2 = abs-int 2
+
+ --test-- "lib2"
+ --assert 2.0 = abs-float -2.0
+
+ --test-- "lib3"
+ s: "hello, world"
+ --assert 12 = strnlen s 32
+ --assert 5 = strnlen s 5
+
+ --test-- "lib4"
+ new: "123456789012"
+ old: "HW"
+ memcpy new old 12
+ --assert new/1 = #"H"
+ --assert new/2 = #"W"
+ --assert 2 = length? new
+ --assert old/1 = #"H"
+ --assert old/2 = #"W"
+ --assert 2 = length? old
+
+===end-group===
+
+===start-group=== "callbacks"
+
+ --test-- "libcallback1"
+ lib-array: declare lt-array!
+ lib-array/a: 4
+ lib-array/b: 3
+ lib-array/c: 2
+ lib-array/d: 1
+ lib-compare: func [
+ [cdecl]
+ first [lt-int!]
+ second [lt-int!]
+ return: [integer!]
+ ][
+ first/i - second/i
+ ]
+ qsort lib-array 4 4 :lib-compare
+ --assert 1 = lib-array/a
+ --assert 2 = lib-array/b
+ --assert 3 = lib-array/c
+ --assert 4 = lib-array/d
+
+===end-group===
+
+#switch OS [
+ Windows [
+ #include %lib-win32-test.reds
+ ]
+ MacOSX [
+ #include %lib-osx-test.reds
+ ]
+]
+
+~~~end-file~~~
+
@@ -0,0 +1,34 @@
+Red/System [
+ Title: "Red/System lib win32 test script"
+ Author: "Peter W A Wood"
+ File: %lib-test-source.reds
+ Rights: "Copyright (C) 2012 Peter W A Wood. All rights reserved."
+ License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
+]
+
+lib-win-int-ptr!: alias struct! [
+ int [integer!]
+]
+
+;; library declarations
+
+#import [
+ "Kernel32.dll" stdcall [
+ get-computer-name: "GetComputerNameA" [
+ name [c-string!]
+ len [lib-win-int-ptr!]
+ return: [logic!]
+ ]
+ ]
+]
+
+===start-group=== "Win32"
+
+ --test-- "libWin32-1"
+ lw1-name: "****************"
+ lw1-len: declare lib-win-int-ptr!
+ lw1-len/int: 15
+ --assert get-computer-name lw1-name lw1-len
+ --assert lw1-name/1 <> #"*"
+
+===end-group===
Binary file not shown.
Oops, something went wrong.

0 comments on commit c215564

Please sign in to comment.