From fc354ffe836720cb88a4a87ac1799b5c9a881a6b Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 21 Apr 2016 19:00:22 +0200 Subject: [PATCH] some .subckt scope regression tests --- tests/regression/lib-processing/Makefile.am | 2 +- tests/regression/lib-processing/scope-1.cir | 70 +++++++++++++++++ tests/regression/lib-processing/scope-1.out | 8 ++ tests/regression/lib-processing/scope-2.cir | 81 ++++++++++++++++++++ tests/regression/lib-processing/scope-2.out | 8 ++ tests/regression/lib-processing/scope-3.cir | 84 +++++++++++++++++++++ tests/regression/lib-processing/scope-3.out | 8 ++ 7 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 tests/regression/lib-processing/scope-1.cir create mode 100644 tests/regression/lib-processing/scope-1.out create mode 100644 tests/regression/lib-processing/scope-2.cir create mode 100644 tests/regression/lib-processing/scope-2.out create mode 100644 tests/regression/lib-processing/scope-3.cir create mode 100644 tests/regression/lib-processing/scope-3.out diff --git a/tests/regression/lib-processing/Makefile.am b/tests/regression/lib-processing/Makefile.am index 920ebed8b..ac8ef3379 100644 --- a/tests/regression/lib-processing/Makefile.am +++ b/tests/regression/lib-processing/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in -TESTS = ex1a.cir ex1b.cir ex2a.cir ex3a.cir +TESTS = ex1a.cir ex1b.cir ex2a.cir ex3a.cir scope-1.cir scope-2.cir scope-3.cir TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice diff --git a/tests/regression/lib-processing/scope-1.cir b/tests/regression/lib-processing/scope-1.cir new file mode 100644 index 000000000..87d3e06f9 --- /dev/null +++ b/tests/regression/lib-processing/scope-1.cir @@ -0,0 +1,70 @@ +scope-1, subckt scopes +* (exec-spice "ngspice -b %s" t) + +* ---- + +i1001_t n1001_t 0 -1mA +x1001_t n1001_t 0 sub1 + +v1001_g n1001_g 0 2.0V + +* ---- + +i1002_t n1002_t 0 -1mA +x1002_t n1002_t 0 sub2 + +v1002_g n1002_g 0 1.0V + +* ---- + +.subckt sub1 n1 n2 +.subckt sub n1 n2 +R1 n1 n2 4k +.ends +X1 n1 n2 sub +R1 n1 n2 4k +.ends + +.subckt sub2 n1 n2 +.subckt sub n1 n2 +R1 n1 n2 2k +.ends +X1 n1 n2 sub +R1 n1 n2 2k +.ends + + +.control + +define mismatch(a,b,err) abs(a-b)>err + +op + +let total_count = 0 +let fail_count = 0 + +let tests = 1001 + vector(2) + +foreach n $&tests + set n_test = "n{$n}_t" + set n_gold = "n{$n}_g" + if mismatch(v($n_test), v($n_gold), 1e-9) + let v_test = v($n_test) + let v_gold = v($n_gold) + echo "ERROR, test failure, v($n_test) = $&v_test but should be $&v_gold" + let fail_count = fail_count + 1 + end + let total_count = total_count + 1 +end + +if fail_count > 0 + echo "ERROR: $&fail_count of $&total_count tests failed" + quit 1 +else + echo "INFO: $&fail_count of $&total_count tests failed" + quit 0 +end + +.endc + +.end diff --git a/tests/regression/lib-processing/scope-1.out b/tests/regression/lib-processing/scope-1.out new file mode 100644 index 000000000..e5abd7ecf --- /dev/null +++ b/tests/regression/lib-processing/scope-1.out @@ -0,0 +1,8 @@ + +Circuit: scope-1, subckt scopes + +Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 + + +No. of Data Rows : 1 +INFO: 0 of 2 tests failed diff --git a/tests/regression/lib-processing/scope-2.cir b/tests/regression/lib-processing/scope-2.cir new file mode 100644 index 000000000..53e48dac9 --- /dev/null +++ b/tests/regression/lib-processing/scope-2.cir @@ -0,0 +1,81 @@ +scope-2, subckt scopes +* (exec-spice "ngspice -b %s" t) + +* ---- + +i1001_t n1001_t 0 -1mA +x1001_t n1001_t 0 sub1 + +v1001_g n1001_g 0 2.0V + +* ---- + +i1002_t n1002_t 0 -1mA +x1002_t n1002_t 0 sub2 + +v1002_g n1002_g 0 1.0V + +* ---- + +i1003_t n1003_t 0 -1mA +x1003_t n1003_t 0 sub + +v1003_g n1003_g 0 3.0V + +* ---- + +.subckt sub1 n1 n2 +.subckt sub n1 n2 +R1 n1 n2 4k +.ends +X1 n1 n2 sub +R1 n1 n2 4k +.ends + +.subckt sub n1 n2 +R1 n1 n2 3k +.ends + +.subckt sub2 n1 n2 +.subckt sub n1 n2 +R1 n1 n2 2k +.ends +X1 n1 n2 sub +R1 n1 n2 2k +.ends + + +.control + +define mismatch(a,b,err) abs(a-b)>err + +op + +let total_count = 0 +let fail_count = 0 + +let tests = 1001 + vector(3) + +foreach n $&tests + set n_test = "n{$n}_t" + set n_gold = "n{$n}_g" + if mismatch(v($n_test), v($n_gold), 1e-9) + let v_test = v($n_test) + let v_gold = v($n_gold) + echo "ERROR, test failure, v($n_test) = $&v_test but should be $&v_gold" + let fail_count = fail_count + 1 + end + let total_count = total_count + 1 +end + +if fail_count > 0 + echo "ERROR: $&fail_count of $&total_count tests failed" + quit 1 +else + echo "INFO: $&fail_count of $&total_count tests failed" + quit 0 +end + +.endc + +.end diff --git a/tests/regression/lib-processing/scope-2.out b/tests/regression/lib-processing/scope-2.out new file mode 100644 index 000000000..edca8c3b5 --- /dev/null +++ b/tests/regression/lib-processing/scope-2.out @@ -0,0 +1,8 @@ + +Circuit: scope-2, subckt scopes + +Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 + + +No. of Data Rows : 1 +INFO: 0 of 3 tests failed diff --git a/tests/regression/lib-processing/scope-3.cir b/tests/regression/lib-processing/scope-3.cir new file mode 100644 index 000000000..2d51bc19d --- /dev/null +++ b/tests/regression/lib-processing/scope-3.cir @@ -0,0 +1,84 @@ +scope-3, subckt scopes +* (exec-spice "ngspice -b %s" t) + +* ---- +* (/ 1 (+ (/ 1.0 2 3 3) (/ 1.0 2 3 5))) + +.param foo = 2k + +i1001_t n1001_t 0 -1mA +x1001_t n1001_t 0 sub1 foo='foo*3' + +v1001_g n1001_g 0 11.25v + +* ---- +* (/ 1 (+ (/ 1.0 2 4 11) (/ 1.0 2 4 13))) +i1002_t n1002_t 0 -1mA +x1002_t n1002_t 0 sub2 foo='foo*4' + +v1002_g n1002_g 0 47.666666666666666 + +* ---- + +i1003_t n1003_t 0 -1mA +x1003_t n1003_t 0 sub foo=3k + +v1003_g n1003_g 0 33.0v + +* ---- + +.subckt sub1 n1 n2 foo=5k +.subckt sub n1 n2 foo=10k +R1 n1 n2 'foo' +.ends +X1 n1 n2 sub foo='3*foo' +R1 n1 n2 '5*foo' +.ends + +.subckt sub n1 n2 foo=17k +R1 n1 n2 'foo*11' +.ends + +.subckt sub2 n1 n2 foo=121k +.subckt sub n1 n2 foo=117k +R1 n1 n2 'foo' +.ends +X1 n1 n2 sub foo='11*foo' +R1 n1 n2 'foo*13' +.ends + + +.control + +define mismatch(a,b,err) abs(a-b)>err + +op + +let total_count = 0 +let fail_count = 0 + +let tests = 1001 + vector(3) + +foreach n $&tests + set n_test = "n{$n}_t" + set n_gold = "n{$n}_g" + if mismatch(v($n_test), v($n_gold), 1e-9) + let v_test = v($n_test) + let v_gold = v($n_gold) + echo "ERROR, test failure, v($n_test) = $&v_test but should be $&v_gold" + let fail_count = fail_count + 1 + end + let total_count = total_count + 1 +end + +if fail_count > 0 + echo "ERROR: $&fail_count of $&total_count tests failed" + quit 1 +else + echo "INFO: $&fail_count of $&total_count tests failed" + quit 0 +end + +.endc + +.end diff --git a/tests/regression/lib-processing/scope-3.out b/tests/regression/lib-processing/scope-3.out new file mode 100644 index 000000000..59fb0602a --- /dev/null +++ b/tests/regression/lib-processing/scope-3.out @@ -0,0 +1,8 @@ + +Circuit: scope-3, subckt scopes + +Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 + + +No. of Data Rows : 1 +INFO: 0 of 3 tests failed