summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blossom2010-10-31 20:52:48 -0700
committerEric Blossom2010-11-10 12:15:43 -0800
commit1f088ee6731f74649cb013a216e4b66b740971b7 (patch)
treea4144db4f5643ae38501a3ef1e105b37ba32b533
parentf2f013ecb94c5e5781952c67496fec09aff7da2c (diff)
downloadgnuradio-1f088ee6731f74649cb013a216e4b66b740971b7.tar.gz
gnuradio-1f088ee6731f74649cb013a216e4b66b740971b7.tar.bz2
gnuradio-1f088ee6731f74649cb013a216e4b66b740971b7.zip
Add simple test for guile bindings.
At this point you must "make install" before running the test.
-rw-r--r--guile/tests/test1.scm36
1 files changed, 36 insertions, 0 deletions
diff --git a/guile/tests/test1.scm b/guile/tests/test1.scm
new file mode 100644
index 000000000..a6211adaa
--- /dev/null
+++ b/guile/tests/test1.scm
@@ -0,0 +1,36 @@
+(use-modules (gnuradio core))
+(use-modules (oop goops))
+(use-modules (ice-9 format))
+(use-modules (ice-9 pretty-print))
+
+(define ep gr:ep)
+
+(define (vector-map f v)
+ (list->vector (map f (vector->list v))))
+
+(define (check-result name a b)
+ (cond ((equal? a b) #t)
+ (else
+ (format 1 "~a: failed:\n expected: ~y\n got:\n~y\n" name a b)
+ #f)))
+
+
+(define (test-1)
+ (let* ((src-data #(-5 -4 -3 -2 -1 0 1 2 3 4 5))
+ (expected-result (vector-map (lambda (x) (* x 2)) src-data))
+ (tb (gr:top-block-swig "my top block"))
+ (src (gr:vector-source-i src-data #f))
+ (op (gr:multiply-const-ii 2))
+ (dst (gr:vector-sink-i)))
+ (gr:connect tb src op dst)
+ ;;(gr:connect tb `(,src 0) `(,op 0))
+ ;;(gr:connect tb `(,op 0) `(,dst 0))
+ ;;(gr:connect tb (ep src 0) (ep op 0))
+ ;;(gr:connect tb (ep op 0) (ep dst 0))
+ ;;(gr:connect tb src op)
+ ;;(gr:connect tb op dst)
+ (gr:run tb)
+ (let ((actual-result (gr:data dst)))
+ ;;(pretty-print actual-result)
+ (check-result 'test-1 expected-result actual-result))))
+