diff --git a/ChangeLog b/ChangeLog index 7426bb2e1..c808e1273 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2011-01-25 Robert Larice + * Modified src/include/cmproto.h , + * Modified src/xspice/icm/dlmain.c , + * Modified src/xspice/icm/digital/d_source/cfunc.mod , + * Modified src/xspice/icm/digital/d_state/cfunc.mod , + * Modified tests/bin/check.sh , + * Added tests/bin/spinit , + * Modified tests/bsim3/dc_sim/Makefile.am , + * Modified tests/bsim3soi/Makefile.am , + * Modified tests/bsim3soidd/Makefile.am , + * Modified tests/bsim3soifd/Makefile.am , + * Modified tests/bsim3soipd/Makefile.am , + * Modified tests/bsim4/Makefile.am , + * Modified tests/xspice/digital/Makefile.am , + * Modified tests/xspice/digital/spinit.in : + fix `make check' for build in a separate directory + 2011-01-25 Robert Larice * Modified configure.ac , * Modified src/xspice/Makefile.am , diff --git a/src/include/cmproto.h b/src/include/cmproto.h index d98eed030..9eab816c3 100755 --- a/src/include/cmproto.h +++ b/src/include/cmproto.h @@ -102,4 +102,6 @@ void *calloc_pj(size_t s1, size_t s2); void *realloc_pj(void *ptr, size_t s); void free_pj(void *ptr); +FILE *fopen_with_path(const char *path, const char *mode); + #endif /* CMPROTO_DEFINED */ diff --git a/src/xspice/icm/digital/d_source/cfunc.mod b/src/xspice/icm/digital/d_source/cfunc.mod index 0f899ed34..4d93e3877 100644 --- a/src/xspice/icm/digital/d_source/cfunc.mod +++ b/src/xspice/icm/digital/d_source/cfunc.mod @@ -1019,7 +1019,7 @@ void cm_d_source(ARGS) /*** open file and count the number of vectors in it ***/ - source = fopen( PARAM(input_file), "r"); + source = fopen_with_path( PARAM(input_file), "r"); /* increment counter if not a comment until EOF reached... */ i = 0; diff --git a/src/xspice/icm/digital/d_state/cfunc.mod b/src/xspice/icm/digital/d_state/cfunc.mod index bf752f249..3fdc87e8c 100644 --- a/src/xspice/icm/digital/d_state/cfunc.mod +++ b/src/xspice/icm/digital/d_state/cfunc.mod @@ -1779,7 +1779,7 @@ void cm_d_state(ARGS) /*** open file and count the number of vectors in it ***/ - state_file = fopen( PARAM(state_file), "r"); + state_file = fopen_with_path( PARAM(state_file), "r"); /* increment counter if not a comment until EOF reached... */ i = 0; diff --git a/src/xspice/icm/dlmain.c b/src/xspice/icm/dlmain.c index e834c6759..da9919800 100644 --- a/src/xspice/icm/dlmain.c +++ b/src/xspice/icm/dlmain.c @@ -388,3 +388,29 @@ void * trealloc(void *ptr, size_t s) { void txfree(void *ptr) { (coreitf->dllitf_txfree)(ptr); } + +#include +#include + +#define MAX_PATH_LEN 1024 + +FILE *fopen_with_path(const char *path, const char *mode) +{ + char buf[MAX_PATH_LEN+1]; + + if(path[0] != '/') { + const char *x = getenv("ngspice_vpath"); + if(x) { + char *a; + strcpy(buf, x); + a = strrchr(buf, '/'); + if(a && a[1] == '\0') + a[0] = '\0'; + strcat(buf, "/"); + strcat(buf, path); + path = buf; + } + } + + return fopen(path, mode); +} diff --git a/tests/bin/check.sh b/tests/bin/check.sh index 2ab6dd422..3813d8299 100644 --- a/tests/bin/check.sh +++ b/tests/bin/check.sh @@ -1,5 +1,19 @@ #!/bin/sh +# set -x + +if [ -z "$SPICE_SCRIPTS" ] ; then + SPICE_SCRIPTS=`dirname $0` + export SPICE_SCRIPTS + if [ -z "$ngspice_vpath" ] ; then + ngspice_vpath=. + export ngspice_vpath + fi +fi + +# ls -ld $(realpath $SPICE_SCRIPTS) $SPICE_SCRIPTS/spinit +# echo "---ngspice_vpath = $ngspice_vpath" + SPICE=$1 TEST=$2 diff --git a/tests/bin/spinit b/tests/bin/spinit new file mode 100644 index 000000000..3be28d032 --- /dev/null +++ b/tests/bin/spinit @@ -0,0 +1,4 @@ +* due to a broken implementation of the ngspice frontend +* this environment variable must be lower-case + +set sourcepath = ( $ngspice_vpath . ) diff --git a/tests/bsim3/dc_sim/Makefile.am b/tests/bsim3/dc_sim/Makefile.am index b82610ee5..f3fa5814d 100644 --- a/tests/bsim3/dc_sim/Makefile.am +++ b/tests/bsim3/dc_sim/Makefile.am @@ -17,7 +17,7 @@ TESTS = \ test14.cir -TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice EXTRA_DIST = \ modelcard.nmos \ diff --git a/tests/bsim3soi/Makefile.am b/tests/bsim3soi/Makefile.am index b0844ff08..b6ce52730 100644 --- a/tests/bsim3soi/Makefile.am +++ b/tests/bsim3soi/Makefile.am @@ -12,7 +12,7 @@ TESTS = \ inv_dc.cir \ inv_tr.cir -TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice EXTRA_DIST = \ nmos4p3.mod \ diff --git a/tests/bsim3soidd/Makefile.am b/tests/bsim3soidd/Makefile.am index ff9e4b691..a12504ae1 100644 --- a/tests/bsim3soidd/Makefile.am +++ b/tests/bsim3soidd/Makefile.am @@ -7,7 +7,7 @@ TESTS = \ inv2.cir \ RampVg2.cir -TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice EXTRA_DIST = \ nmosdd.mod \ diff --git a/tests/bsim3soifd/Makefile.am b/tests/bsim3soifd/Makefile.am index 8cbf17373..b1c55f515 100644 --- a/tests/bsim3soifd/Makefile.am +++ b/tests/bsim3soifd/Makefile.am @@ -7,7 +7,7 @@ TESTS = \ inv2.cir \ RampVg2.cir -TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice EXTRA_DIST = \ nmosfd.mod \ diff --git a/tests/bsim3soipd/Makefile.am b/tests/bsim3soipd/Makefile.am index 271ec189c..9ab5c91ba 100644 --- a/tests/bsim3soipd/Makefile.am +++ b/tests/bsim3soipd/Makefile.am @@ -7,7 +7,7 @@ TESTS = \ inv2.cir \ RampVg2.cir -TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice EXTRA_DIST = \ nmospd.mod \ diff --git a/tests/bsim4/Makefile.am b/tests/bsim4/Makefile.am index 0f579e283..c06d66294 100644 --- a/tests/bsim4/Makefile.am +++ b/tests/bsim4/Makefile.am @@ -21,7 +21,7 @@ TESTS = \ opamp.cir \ ro_17.cir -TESTS_ENVIRONMENT = $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice EXTRA_DIST = \ modelcard.nmos \ diff --git a/tests/xspice/digital/Makefile.am b/tests/xspice/digital/Makefile.am index 69984d39c..c89536eeb 100644 --- a/tests/xspice/digital/Makefile.am +++ b/tests/xspice/digital/Makefile.am @@ -5,7 +5,7 @@ TESTS = \ d_source.cir \ d_state.cir -TESTS_ENVIRONMENT = SPICE_SCRIPTS=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh "$(top_builddir)/src/ngspice -r foobaz" +TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) SPICE_SCRIPTS=. $(SHELL) $(top_srcdir)/tests/bin/check.sh "$(top_builddir)/src/ngspice -r foobaz" EXTRA_DIST = \ d_ram-stimulus.txt \ diff --git a/tests/xspice/digital/spinit.in b/tests/xspice/digital/spinit.in index 46ddecd36..df695bfbc 100644 --- a/tests/xspice/digital/spinit.in +++ b/tests/xspice/digital/spinit.in @@ -1 +1,2 @@ codemodel @top_builddir@/src/xspice/icm/digital/digital.cm +set sourcepath = ( $ngspice_vpath . )