diff options
author | Rob Savoye | 2010-11-21 21:49:17 -0700 |
---|---|---|
committer | Rob Savoye | 2010-11-21 21:49:17 -0700 |
commit | 534d95dcadcd4351337ba3fd97a2c94405bc6124 (patch) | |
tree | 5384896921f7050ed4004f6543e55f617fad6ee0 /gnuradio-core/src/guile | |
parent | 9cf988ad17529416f841870b01d0f548e1a0b9a0 (diff) | |
parent | e4eb47f0dd55485693e70ec2f45f79912fa899c4 (diff) | |
download | gnuradio-534d95dcadcd4351337ba3fd97a2c94405bc6124.tar.gz gnuradio-534d95dcadcd4351337ba3fd97a2c94405bc6124.tar.bz2 gnuradio-534d95dcadcd4351337ba3fd97a2c94405bc6124.zip |
merge from upstream
Diffstat (limited to 'gnuradio-core/src/guile')
-rw-r--r-- | gnuradio-core/src/guile/gnuradio/runtime-shim.scm | 42 | ||||
-rw-r--r-- | gnuradio-core/src/guile/run_guile_tests.in | 12 | ||||
-rw-r--r-- | gnuradio-core/src/guile/tests/00_runtime_ctors.test | 19 | ||||
-rw-r--r-- | gnuradio-core/src/guile/tests/general_ctors.test | 20 | ||||
-rw-r--r-- | gnuradio-core/src/guile/tests/gengen_ctors.test | 18 | ||||
-rw-r--r-- | gnuradio-core/src/guile/tests/io_ctors.test | 49 |
6 files changed, 110 insertions, 50 deletions
diff --git a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm index c08d3947c..bba702670 100644 --- a/gnuradio-core/src/guile/gnuradio/runtime-shim.scm +++ b/gnuradio-core/src/guile/gnuradio/runtime-shim.scm @@ -19,6 +19,7 @@ (define-module (gnuradio runtime-shim) #:use-module (oop goops) + #:use-module (ice-9 threads) #:use-module (gnuradio gnuradio_core_runtime) #:duplicates (merge-generics replace check)) @@ -86,4 +87,43 @@ (loop (1+ n)))))))))) -(export-safely <gr-endpoint> gr:ep gr:connect gr:disconnect) + + +(define-method (gr:run (self <gr-top-block-sptr>)) + (gr:start self) + (gr:wait self)) + + +(define-method (gr:wait (tb <gr-top-block-sptr>)) + + (define (sigint-handler sig) + ;;(display "\nSIGINT!\n" (current-error-port)) + ;; tell flow graph to stop + (gr:stop tb)) + + (let ((old-handler #f)) + (dynamic-wind + + ;; Called at entry + (lambda () + ;; Install SIGINT handler + (set! old-handler (sigaction SIGINT sigint-handler))) + + ;; Protected thunk + (lambda () + (let ((waiter (begin-thread (gr:top-block-wait-unlocked tb)))) + (join-thread waiter) + ;;(display "\nAfter join-thread\n" (current-error-port)) + )) + + ;; Called at exit + (lambda () + ;; Restore SIGINT handler + (if (not (car old-handler)) + ;; restore original C handler + (sigaction SIGINT #f) + ;; restore Scheme handler, SIG_IGN or SIG_DFL + (sigaction SIGINT (car old-handler) (cdr old-handler))))))) + + +(export-safely <gr-endpoint> gr:ep gr:connect gr:disconnect gr:run gr:wait) diff --git a/gnuradio-core/src/guile/run_guile_tests.in b/gnuradio-core/src/guile/run_guile_tests.in index 3aca7bdb0..61968065e 100644 --- a/gnuradio-core/src/guile/run_guile_tests.in +++ b/gnuradio-core/src/guile/run_guile_tests.in @@ -2,14 +2,16 @@ . @top_builddir@/setup_guile_test_env +# Since we're in gnuradio-core, we don't need to add anything, +# but we do need to call add_local_paths to set everything up + # 1st argument is absolute path to hand coded guile source directory # 2nd argument is absolute path to component C++ shared library build directory # 3nd argument is absolute path to component SWIG build directory -# We're in gnuradio-core, we don't need these -# add_local_paths \ -# "" \ -# "" \ -# "" +add_local_paths \ + "" \ + "" \ + "" @GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@/tests diff --git a/gnuradio-core/src/guile/tests/00_runtime_ctors.test b/gnuradio-core/src/guile/tests/00_runtime_ctors.test index 0c131f5bd..966d8c909 100644 --- a/gnuradio-core/src/guile/tests/00_runtime_ctors.test +++ b/gnuradio-core/src/guile/tests/00_runtime_ctors.test @@ -32,4 +32,23 @@ ;;; Add test code for all constructors in these files ;;; ;;; ./runtime/gr_hier_block2.h + ;;; ./runtime/gr_msg_queue.h + +(define (equal-message? a b) + (equal? (gr:to-string a) (gr:to-string b))) + +(with-test-prefix "gr:message/gr:msg-queue" + (let ((msg1 (gr:message-from-string "Hello")) + (msg2 (gr:message-from-string "World!")) + (q (gr:msg-queue))) + (pass-if (equal? "Hello" (gr:to-string msg1))) + (pass-if (equal? "World!" (gr:to-string msg2))) + (pass-if (gr:empty-p q)) + (gr:insert-tail q msg1) + (pass-if (not (gr:empty-p q))) + (gr:insert-tail q msg2) + (let ((r1 (gr:delete-head q)) + (r2 (gr:delete-head q))) + (pass-if (equal-message? r1 msg1)) + (pass-if (equal-message? r2 msg2))))) diff --git a/gnuradio-core/src/guile/tests/general_ctors.test b/gnuradio-core/src/guile/tests/general_ctors.test index d09766a95..ff5ee74fa 100644 --- a/gnuradio-core/src/guile/tests/general_ctors.test +++ b/gnuradio-core/src/guile/tests/general_ctors.test @@ -259,18 +259,18 @@ ;;; ./general/gr_ofdm_frame_acquisition.h (pass-if (true? (gr:ofdm-frame-acquisition 1 1 1 #(1+3i 23+5i) 1))) -;;; ./general/gr_ofdm_frame_sink.h FIXME: "No matching method for generic function `ofdm_frame_sink'" -;; (pass-if (true? (gr:ofdm-frame-sink #(1+3i 23+5i) #('a' 'b') (gr:msg-queue) 1 0.25 0))) +;;; ./general/gr_ofdm_frame_sink.h +(pass-if (true? (gr:ofdm-frame-sink #(1+3i 23+5i) #(0 1) (gr:msg-queue) 128 0.25 0))) ;;; ./general/gr_ofdm_insert_preamble.h FIXME: "Wrong type argument in position ~A: ~S" -;; (pass-if (true? (gr:ofdm-insert-preamble 1 #(#(1+3i 23+5i))))) - -;;; ./general/gr_ofdm_mapper_bcv.h FIXME: Wrong type argument in position ~A: -;; gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, -;; unsigned int msgq_limit, -;; unsigned int bits_per_symbol, -;; unsigned int fft_length); -;; (pass-if (true? (gr:ofdm-mapper-bcv #(1+3i 23+5i) 1 1 1))) +;;; WONTFIX: Need vector<vector<complex<float>>> +;;(pass-if (true? (gr:ofdm-insert-preamble 2 #(#(1+3i 23+5i) #(1+3i 23+5i))))) + +;;; ./general/gr_ofdm_mapper_bcv.h +(pass-if (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 100 128))) +(pass-if-throw "confirm throw gr:ofdm-mapper-bcv" #t + (true? (gr:ofdm-mapper-bcv #(0+1i 0-1i) 1 10 128))) + ;;; ./general/gr_ofdm_sampler.h (pass-if (true? (gr:ofdm-sampler 1 1 1))) diff --git a/gnuradio-core/src/guile/tests/gengen_ctors.test b/gnuradio-core/src/guile/tests/gengen_ctors.test index 43996c001..6e1213c63 100644 --- a/gnuradio-core/src/guile/tests/gengen_ctors.test +++ b/gnuradio-core/src/guile/tests/gengen_ctors.test @@ -198,16 +198,16 @@ (pass-if (true? (gr:multiply-ss 1))) ;;; ./gengen/gr_mute_cc.h FIXME: not found -;; (pass-if (true? (gr:mute-cc false))) +(pass-if (true? (gr:mute-cc #f))) ;;; ./gengen/gr_mute_ff.h FIXME: not found -;;(pass-if (true? (gr:mute-ff false))) +(pass-if (true? (gr:mute-ff #f))) ;;; ./gengen/gr_mute_ii.h FIXME: not found -;; (pass-if (true? (gr:mute-ii false))) +(pass-if (true? (gr:mute-ii #f))) ;;; ./gengen/gr_mute_ss.h FIXME: not found -;; (pass-if (true? (gr:mute-ss false))) +(pass-if (true? (gr:mute-ss #f))) ;;; ./gengen/gr_noise_source_c.h (pass-if (true? (gr:noise-source-c 1 0 3021))) @@ -318,19 +318,19 @@ (pass-if (true? (gr:vector-sink-s 1))) ;;; ./gengen/gr_vector_source_b.h -;; (pass-if (true? (gr:vector-source-b #(1 2) false 1))) +;; (pass-if (true? (gr:vector-source-b #(1 2) #f 1))) ;; ;;; ./gengen/gr_vector_source_c.h -;; (pass-if (true? (gr:vector-source-c #(1+3i 23+5i) false 1))) +;; (pass-if (true? (gr:vector-source-c #(1+3i 23+5i) #f 1))) ;; ;;; ./gengen/gr_vector_source_f.h -;; (pass-if (true? (gr:vector-source-f #(1.0 2.0) false 1))) +;; (pass-if (true? (gr:vector-source-f #(1.0 2.0) #f 1))) ;;; ./gengen/gr_vector_source_i.h -;; (pass-if (true? (gr:vector-source-i #(1 2) false 1))) +;; (pass-if (true? (gr:vector-source-i #(1 2) #f 1))) ;;; ./gengen/gr_vector_source_s.h FIXME: not found -;; (pass-if (true? (gr:vector-source-s #(1 2) false 1))) +;; (pass-if (true? (gr:vector-source-s #(1 2) #f 1))) ;;; ./gengen/gr_xor_bb.h (pass-if (true? (gr:xor-bb))) diff --git a/gnuradio-core/src/guile/tests/io_ctors.test b/gnuradio-core/src/guile/tests/io_ctors.test index 99c84ae37..1c5c9a771 100644 --- a/gnuradio-core/src/guile/tests/io_ctors.test +++ b/gnuradio-core/src/guile/tests/io_ctors.test @@ -37,20 +37,21 @@ ;;; ;;; ./io/gr_file_descriptor_sink.h -(pass-if (true? (gr:file-descriptor-sink 1 1))) +(pass-if (true? (gr:file-descriptor-sink 1 (dup 1)))) -;;; ./io/gr_file_descriptor_source.h FIXME: not found -;; (pass-if (true? (gr:file-descriptor-source 1 1 #f))) +;;; ./io/gr_file_descriptor_source.h +(pass-if (true? (gr:file-descriptor-source 1 (dup 0) #f))) ;;; ./io/gr_file_sink.h (pass-if (true? (gr:file-sink 1 "foo"))) -;;; ./io/gr_file_source.h FIXME: not found -;; (pass-if (true? (gr:file-source 1 "foo" #f))) +;;; ./io/gr_file_source.h +(pass-if (true? (gr:file-source 1 "foo" #f))) +(rm-foo) -;;; ./io/gr_histo_sink_f.h FIXME: not found +;;; ./io/gr_histo_sink_f.h ;; gr_make_histo_sink_f (gr_msg_queue_sptr msgq); -;; (pass-if (true? (gr:histo-sink-f 1))) +(pass-if (true? (gr:histo-sink-f (gr:msg-queue)))) ;;; ./io/gr_message_sink.h (pass-if (true? (gr:message-sink 1 (gr:msg-queue) #f))) @@ -59,25 +60,23 @@ (pass-if (true? (gr:message-source 1 1))) (pass-if (true? (gr:message-source 1 (gr:msg-queue)))) -;;; ./io/gr_oscope_sink_f.h FIXME: not found -;; _oscope_sink_x (const std::string name, gr_io_signature_sptr input_sig, -;; double sample_rate); -;; (pass-if (true? (gr:oscope-sink-f "foo" 1 1))) +;;; ./io/gr_oscope_sink_f.h +(pass-if (true? (gr:oscope-sink-f 1000 (gr:msg-queue)))) -;;; ./io/gr_oscope_sink_x.h FIXME: not found -;; gr_oscope_sink_x (const std::string name, gr_io_signature_sptr input_sig, -;; double sampling_rate); -;; (pass-if (true? (gr:oscope_sink_x "foo" 1 1))) +;;; ./io/gr_udp_sink.h +(pass-if (true? (gr:udp-sink 4 "localhost" 80 1472 #f))) +(pass-if-throw "confirm throw gr:udp-sink" #t + (true? (gr:udp-sink 4 "localhostx" 80 1472 #f))) -;;; ./io/gr_udp_sink.h FIXME: not found -;; (pass-if (true? (gr:udp-sink 1 "foo" 1472 #t))) +;;; ./io/gr_udp_source.h +(pass-if (true? (gr:udp-source 4 "localhost" 0 1472 #f #t))) +(pass-if-throw "confirm throw gr:udp-sink" #t + (true? (gr:udp-source 4 "localhostx" 0 1472 #f #t))) -;;; ./io/gr_udp_source.h FIXME: not found -;; (pass-if (true? (gr:message-source 0 "foo" 0 1472 #t #t))) - -;;; ./io/gr_wavfile_sink.h FIXME: not found -;; (pass-if (true? (gr:message-source "foo" 1 1 1))) - -;;; ./io/gr_wavfile_source.h FIXME: not found -;; (pass-if (true? (gr:message-source "foo" #f))) +;;; ./io/gr_wavfile_sink.h +(pass-if (true? (gr:wavfile-sink "foo" 2 48000 16))) +;;; ./io/gr_wavfile_source.h WONTFIX: buggy source won't accept file +;;; created immediately above. +;;(pass-if (true? (gr:wavfile-source "foo" #f))) +(rm-foo) |