From c1b0c1bac10c8e4c570347c684eb0d91de8d4a62 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 15 Feb 2016 17:09:44 -0500 Subject: [PATCH 01/22] libCom/misc: testMain for RTEMS give weak alias for main() Allows tests to be linked separately or in a common test harness --- src/libCom/misc/testMain.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libCom/misc/testMain.h b/src/libCom/misc/testMain.h index 4db72c39e..7c4d9b29b 100644 --- a/src/libCom/misc/testMain.h +++ b/src/libCom/misc/testMain.h @@ -27,7 +27,13 @@ * } */ -#if defined(vxWorks) || defined(__rtems__) +#if defined(__rtems__) + #ifdef __cplusplus + #define MAIN(prog) extern "C" int prog(void); extern "C" int main() __attribute__((weak, alias(#prog))); extern "C" int prog(void) + #else + #define MAIN(prog) int prog(); int main() __attribute__((weak, alias(#prog))); int prog() + #endif +#elif defined(vxWorks) #ifdef __cplusplus #define MAIN(prog) extern "C" int prog(void) #else From 15b97f65cbde688972986173504700eb38ed1362 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 15 Feb 2016 17:09:44 -0500 Subject: [PATCH 02/22] src/tools: teach makeTestfile about WINE and QEMU Teach makeTestfile host to run test for some cross built targets. --- configure/RULES_BUILD | 2 +- src/tools/makeTestfile.pl | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index ea84db8be..5d335c126 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -380,7 +380,7 @@ endif # Generate a perl program to exec the real test binary. %.t: %$(EXE) $(TOOLS)/makeTestfile.pl @$(RM) $@ - $(PERL) $(TOOLS)/makeTestfile.pl $@ $< + $(PERL) $(TOOLS)/makeTestfile.pl "$(T_A)" $(EPICS_HOST_ARCH) $@ $< #--------------------------------------------------------------- # Generate header with version number from VCS diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index be4648258..73f522034 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -15,13 +15,38 @@ # If the script is given an argument -tap it sets HARNESS_ACTIVE in the # environment to make the epicsUnitTest code generate strict TAP output. -# Usage: makeTestfile.pl target.t executable +# Usage: makeTestfile.pl target.t executable +# target-arch and host-arch are EPICS build target names (eg. linux-x86) # target.t is the name of the Perl script to generate # executable is the name of the file the script runs use strict; -my ($target, $exe) = @ARGV; +my ($TA, $HA, $target, $exe) = @ARGV; +my $exec; + +# Use WINE to run windows target executables on non-windows host +if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { + # new deb. derivatives have wine32 and wine64 + # older have wine and wine64 + # prefer wine32 if present + my $wine32 = "/usr/bin/wine32"; + $wine32 = "/usr/bin/wine" if ! -x $wine32; + $exec = "$wine32 $exe"; +} elsif( $TA =~ /^windows-x64/ && $HA !~ /^win/ ) { + $exec = "wine64 $exe"; + +# Run pc386 test harness w/ QEMU +} elsif( $TA =~ /^RTEMS-pc386$/ ) { + $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=ne2k_pci -net user,restrict=yes -kernel $exe"; + +# Explicitly fail for other RTEMS targets +} elsif( $TA =~ /^RTEMS-/ ) { + die "I don't know how to run tests for $TA on $HA"; + +} else { + $exec = "./$exe"; +} open(my $OUT, '>', $target) or die "Can't create $target: $!\n"; @@ -34,14 +59,7 @@ use Cwd 'abs_path'; \$ENV{HARNESS_ACTIVE} = 1 if scalar \@ARGV && shift eq '-tap'; \$ENV{TOP} = abs_path(\$ENV{TOP}) if exists \$ENV{TOP}; -if (\$^O eq 'MSWin32') { - # Use system on Windows, exec doesn't work the same there and - # GNUmake thinks the test has finished as soon as Perl exits. - system('./$exe') == 0 or die "Can't run $exe: \$!\\n"; -} -else { - exec './$exe' or die "Can't run $exe: \$!\\n"; -} +system('$exec') == 0 or die "Can't run $exec: \$!\\n"; EOF close $OUT or die "Can't close $target: $!\n"; From 684fe10d8c2685c168fc9981ddbe2c266694996a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 15 Feb 2016 17:09:44 -0500 Subject: [PATCH 03/22] RTEMS: Add epicsMemFs and hook for app specific FS setup Default falls back to network FS. Compile in a set of files as a epicsMemFS structure. epicsMemFsLoad() creates a set of files based on this. --- src/libCom/RTEMS/Makefile | 2 + src/libCom/RTEMS/epicsMemFs.c | 110 +++++++++++++++++++++++++ src/libCom/RTEMS/epicsMemFs.h | 24 ++++++ src/libCom/RTEMS/epicsRtemsInitHooks.h | 2 + src/libCom/RTEMS/rtems_init.c | 31 ++++++- src/tools/Makefile | 1 + src/tools/epicsMakeMemFs.pl | 83 +++++++++++++++++++ 7 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 src/libCom/RTEMS/epicsMemFs.c create mode 100644 src/libCom/RTEMS/epicsMemFs.h create mode 100644 src/tools/epicsMakeMemFs.pl diff --git a/src/libCom/RTEMS/Makefile b/src/libCom/RTEMS/Makefile index 4c0b64c04..8652c669b 100644 --- a/src/libCom/RTEMS/Makefile +++ b/src/libCom/RTEMS/Makefile @@ -10,6 +10,7 @@ TOP=../../.. include $(TOP)/configure/CONFIG INC += epicsRtemsInitHooks.h +INC += epicsMemFs.h rtemsCom_SRCS += rtems_init.c rtemsCom_SRCS += rtems_config.c @@ -18,6 +19,7 @@ rtemsCom_SRCS += rtems_util.c rtemsCom_SRCS += setBootConfigFromNVRAM.c rtemsCom_SRCS += epicsRtemsInitHookPre.c rtemsCom_SRCS += epicsRtemsInitHookPost.c +rtemsCom_SRCS += epicsMemFs.c LIBRARY_RTEMS = rtemsCom diff --git a/src/libCom/RTEMS/epicsMemFs.c b/src/libCom/RTEMS/epicsMemFs.c new file mode 100644 index 000000000..4689d210f --- /dev/null +++ b/src/libCom/RTEMS/epicsMemFs.c @@ -0,0 +1,110 @@ +/*************************************************************************\ +* Copyright (c) 2014 Brookhaven National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include + +#include "epicsMemFs.h" + +#ifndef PATH_MAX +# define PATH_MAX 100 +#endif + +int epicsMemFsLoad(const epicsMemFS *fs) +{ + char initdir[PATH_MAX]; + const epicsMemFile * const *fileptr = fs->files; + + if(getcwd(initdir, sizeof(initdir)-1)==NULL) { + perror("getcwd"); + return errno; + } + initdir[sizeof(initdir)-1] = '\0'; + + for(;*fileptr; fileptr++) { + const epicsMemFile *curfile = *fileptr; + int fd; + ssize_t ret; + size_t sofar; + const char * const *dir = curfile->directory; + /* jump back to the root each time, + * slow but simple. + */ + if(chdir(initdir)) { + perror("chdir"); + return errno; + } + + printf("-> /"); + + /* traverse directory tree, creating as necessary */ + for(;*dir; dir++) { + int ret; + if(**dir=='.') continue; /* ignore '.' and '..' */ + printf("%s/", *dir); + ret = chdir(*dir); + if(ret==-1 && errno==ENOENT) { + /* this directory doesn't exist */ + if(mkdir(*dir,0744)==-1) { + printf("\n"); + perror("mkdir"); + return errno; + } + if(chdir(*dir)==-1) { + printf("\n"); + perror("chdir2"); + return errno; + } + } else if(ret==-1) { + printf("\n"); + perror("chdir1"); + return errno; + } + } + + /* no file name creates an empty directory */ + if(!curfile->name) { + printf("\n"); + continue; + } + printf("%s", curfile->name); + + /* create or overwrite */ + fd = open(curfile->name, O_WRONLY|O_CREAT|O_TRUNC, 0644); + + if(fd==-1) { + printf("\n"); + perror("open"); + return errno; + } + + sofar = 0; + + while(sofarsize) { + ret = write(fd, curfile->data+sofar, curfile->size-sofar); + if(ret<=0) { + printf("\n"); + perror("write"); + return errno; + } + sofar += ret; + } + + close(fd); + printf(" - ok\n"); + } + + if(chdir(initdir)) + perror("chdir"); + + return 0; +} diff --git a/src/libCom/RTEMS/epicsMemFs.h b/src/libCom/RTEMS/epicsMemFs.h new file mode 100644 index 000000000..c57f4d793 --- /dev/null +++ b/src/libCom/RTEMS/epicsMemFs.h @@ -0,0 +1,24 @@ +/*************************************************************************\ +* Copyright (c) 2014 Brookhaven National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +#ifndef EPICSMEMFS_H +#define EPICSMEMFS_H + +#include + +typedef struct { + const char * const *directory; /* NULL terminated list of directories */ + const char *name; /* file name */ + const char *data; /* file contents */ + size_t size; /* size of file contents in bytes */ +} epicsMemFile; + +typedef struct { + const epicsMemFile * const *files; +} epicsMemFS; + +int epicsMemFsLoad(const epicsMemFS *fs); + +#endif // EPICSMEMFS_H diff --git a/src/libCom/RTEMS/epicsRtemsInitHooks.h b/src/libCom/RTEMS/epicsRtemsInitHooks.h index b7f09c100..4313f19e3 100644 --- a/src/libCom/RTEMS/epicsRtemsInitHooks.h +++ b/src/libCom/RTEMS/epicsRtemsInitHooks.h @@ -21,3 +21,5 @@ extern char *env_nfsMountPoint; */ int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); +/* Return 0 if local file system was setup, or non-zero (will fall back to network */ +int epicsRtemsMountLocalFilesystem(char **argv); diff --git a/src/libCom/RTEMS/rtems_init.c b/src/libCom/RTEMS/rtems_init.c index 82871da0d..4e8298a29 100644 --- a/src/libCom/RTEMS/rtems_init.c +++ b/src/libCom/RTEMS/rtems_init.c @@ -42,6 +42,7 @@ #include "osiUnistd.h" #include "iocsh.h" #include "osdTime.h" +#include "epicsMemFs.h" #include "epicsRtemsInitHooks.h" @@ -138,6 +139,31 @@ mustMalloc(int size, const char *msg) # include #endif +const epicsMemFS *epicsRtemsFSImage __attribute__((weak)); +const epicsMemFS *epicsRtemsFSImage = (void*)&epicsRtemsFSImage; + +/* hook to allow app specific FS setup */ +int +epicsRtemsMountLocalFilesystem(char **argv) __attribute__((weak)); +int +epicsRtemsMountLocalFilesystem(char **argv) +{ + if(epicsRtemsFSImage==(void*)&epicsRtemsFSImage) + return -1; /* no FS image provided. */ + else if(epicsRtemsFSImage==NULL) + return 0; /* no FS image provided, but none is needed. */ + else { + printf("***** Using compiled in file data *****\n"); + if (epicsMemFsLoad(epicsRtemsFSImage) != 0) { + printf("Can't unpack tar filesystem\n"); + return -1; + } else { + argv[1] = "/"; + return 0; + } + } +} + static int initialize_local_filesystem(char **argv) { @@ -146,7 +172,9 @@ initialize_local_filesystem(char **argv) extern char _FlashSize[] __attribute__((weak)); argv[0] = rtems_bsdnet_bootp_boot_file_name; - if (_FlashSize && (_DownloadLocation || _FlashBase)) { + if (epicsRtemsMountLocalFilesystem(argv)==0) { + return 1; /* FS setup successful */ + } else if (_FlashSize && (_DownloadLocation || _FlashBase)) { extern char _edata[]; size_t flashIndex = _edata - _DownloadLocation; char *header = _FlashBase + flashIndex; @@ -596,6 +624,7 @@ Init (rtems_task_argument ignored) } printf("\n***** Initializing network *****\n"); rtems_bsdnet_initialize_network(); + printf("\n***** Setting up file system *****\n"); initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); fixup_hosts(); diff --git a/src/tools/Makefile b/src/tools/Makefile index e7457ae67..0e27c9340 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -48,6 +48,7 @@ PERL_SCRIPTS += mkmf.pl PERL_SCRIPTS += munch.pl PERL_SCRIPTS += replaceVAR.pl PERL_SCRIPTS += tap-to-junit-xml.pl +PERL_SCRIPTS += epicsMakeMemFs.pl PERL_SCRIPTS += useManifestTool.pl PERL_SCRIPTS += genVersionHeader.pl diff --git a/src/tools/epicsMakeMemFs.pl b/src/tools/epicsMakeMemFs.pl new file mode 100644 index 000000000..a97074e0e --- /dev/null +++ b/src/tools/epicsMakeMemFs.pl @@ -0,0 +1,83 @@ +#!/usr/bin/env perl +# + +use File::Basename; + +use strict; + +my $outfile = shift; +my $varname = shift; + +open(my $DST, '>', $outfile) or die "Failed to open $outfile"; + +print $DST < +EOF + +my $N = 0; + +for my $fname (@ARGV) { + print "<- $fname\n"; + my $realfname = $fname; + + # strip leading "../" "./" or "/" + while ($fname =~ /^\.*\/(.*)$/) { $fname = $1; } + + my $file = basename($fname); + my @dirs = split('/', dirname($fname)); + + print $DST "/* begin $realfname */\nstatic const char * const file_${N}_dir[] = {"; + for my $dpart (@dirs) { + print $DST "\"$dpart\", "; + } + print $DST "NULL};\nstatic const char file_${N}_data[] = {\n "; + + open(my $SRC, '<', $realfname) or die "Failed to open $realfname"; + binmode($SRC); + + my $buf; + my $total = 0; + while (my $num = read($SRC, $buf, 32)) { + if($total != 0) { + print $DST ",\n "; + } + $total += $num; + my $out = join(",",map(ord,split(//,$buf))); + print $DST "$out"; + } + + close($SRC); + + print $DST < Date: Sat, 18 Mar 2017 20:11:55 -0400 Subject: [PATCH 04/22] RTEMS: build self contained test harness Test data stub as a separate file to allow linking into test harness and individual tests. --- src/ioc/db/test/Makefile | 4 ++++ src/libCom/test/Makefile | 2 ++ src/libCom/test/rtemsTestData.c | 6 ++++++ src/std/filters/test/Makefile | 5 +++++ src/std/rec/test/Makefile | 5 +++++ 5 files changed, 22 insertions(+) create mode 100644 src/libCom/test/rtemsTestData.c diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index 37ec3da74..d8ca0f15b 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -175,6 +175,8 @@ testHarness_SRCS += epicsRunDbTests.c dbTestHarness_SRCS += $(testHarness_SRCS) dbTestHarness_SRCS_RTEMS += rtemsTestHarness.c +PROD_SRCS_RTEMS += rtemsTestData.c + PROD_vxWorks = dbTestHarness PROD_RTEMS = dbTestHarness @@ -193,3 +195,5 @@ devx$(DEP): $(COMMON_DIR)/xRecord.h scanIoTest$(DEP): $(COMMON_DIR)/xRecord.h xRecord$(DEP): $(COMMON_DIR)/xRecord.h +rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl + $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES) diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 04438854c..9b3b7dacd 100755 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -13,6 +13,8 @@ include $(TOP)/configure/CONFIG PROD_LIBS += Com PROD_SYS_LIBS_WIN32 += ws2_32 advapi32 user32 +PROD_SRCS_RTEMS += rtemsTestData.c + TESTPROD_HOST += epicsUnitTestTest epicsUnitTestTest_SRCS += epicsUnitTestTest.c # Not much point running this on vxWorks or RTEMS... diff --git a/src/libCom/test/rtemsTestData.c b/src/libCom/test/rtemsTestData.c new file mode 100644 index 000000000..7b68976c5 --- /dev/null +++ b/src/libCom/test/rtemsTestData.c @@ -0,0 +1,6 @@ +#include "epicsMemFs.h" + +/* no local files needed for these tests, + * so skip local FS setup + */ +const epicsMemFS *epicsRtemsFSImage = NULL; diff --git a/src/std/filters/test/Makefile b/src/std/filters/test/Makefile index 6e6ad79c6..1c8efd1a1 100644 --- a/src/std/filters/test/Makefile +++ b/src/std/filters/test/Makefile @@ -62,6 +62,8 @@ testHarness_SRCS += epicsRunFilterTests.c filterTestHarness_SRCS += $(testHarness_SRCS) filterTestHarness_SRCS_RTEMS += rtemsTestHarness.c +PROD_SRCS_RTEMS += rtemsTestData.c + PROD_vxWorks = filterTestHarness PROD_RTEMS = filterTestHarness @@ -78,3 +80,6 @@ dbndTest$(DEP): $(COMMON_DIR)/xRecord.h syncTest$(DEP): $(COMMON_DIR)/xRecord.h arrRecord$(DEP): $(COMMON_DIR)/arrRecord.h arrTest$(DEP): $(COMMON_DIR)/arrRecord.h + +rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl + $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES) diff --git a/src/std/rec/test/Makefile b/src/std/rec/test/Makefile index 5a591b230..5619f491a 100644 --- a/src/std/rec/test/Makefile +++ b/src/std/rec/test/Makefile @@ -110,6 +110,8 @@ testHarness_SRCS += epicsRunRecordTests.c recordTestHarness_SRCS += $(testHarness_SRCS) recordTestHarness_SRCS_RTEMS += rtemsTestHarness.c +PROD_SRCS_RTEMS += rtemsTestData.c + PROD_vxWorks = recordTestHarness PROD_RTEMS = recordTestHarness @@ -119,3 +121,6 @@ TESTSPEC_RTEMS = recordTestHarness.boot; epicsRunRecordTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) include $(TOP)/configure/RULES + +rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl + $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES) From 12da38a7ca5cff6a77da86cc07fc96417091bfd9 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 18 Mar 2017 20:12:02 -0400 Subject: [PATCH 05/22] build/run RTEMS-pc386 tests individually Build and run individual test executable in addition to the test harness. Individual tests run with 'make runtests'. omit epicsUnitTestTest as it has a custom .plt --- src/ioc/db/test/Makefile | 4 ++++ src/libCom/test/Makefile | 4 ++++ src/std/filters/test/Makefile | 4 ++++ src/std/rec/test/Makefile | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index d8ca0f15b..baa381534 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -184,6 +184,10 @@ TESTSPEC_vxWorks = dbTestHarness.munch; epicsRunDbTests TESTSPEC_RTEMS = dbTestHarness.boot; epicsRunDbTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) +ifeq ($(T_A),RTEMS-pc386) +TESTPROD_RTEMS = $(TESTPROD_HOST) +TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) +endif include $(TOP)/configure/RULES diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 9b3b7dacd..0aba60e32 100755 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -230,6 +230,10 @@ TESTSPEC_vxWorks = libComTestHarness.munch; epicsRunLibComTests TESTSPEC_RTEMS = libComTestHarness.boot; epicsRunLibComTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) +ifeq ($(T_A),RTEMS-pc386) +TESTPROD_RTEMS = $(TESTPROD_HOST) +TESTSCRIPTS_RTEMS += $(filter-out epicsUnitTestTest.t, $(TESTS:%=%.t)) +endif # The following are not test programs, they measure performance. diff --git a/src/std/filters/test/Makefile b/src/std/filters/test/Makefile index 1c8efd1a1..6442ba332 100644 --- a/src/std/filters/test/Makefile +++ b/src/std/filters/test/Makefile @@ -71,6 +71,10 @@ TESTSPEC_vxWorks = filterTestHarness.munch; epicsRunFilterTests TESTSPEC_RTEMS = filterTestHarness.boot; epicsRunFilterTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) +ifeq ($(T_A),RTEMS-pc386) +TESTPROD_RTEMS = $(TESTPROD_HOST) +TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) +endif include $(TOP)/configure/RULES diff --git a/src/std/rec/test/Makefile b/src/std/rec/test/Makefile index 5619f491a..f5f9b4312 100644 --- a/src/std/rec/test/Makefile +++ b/src/std/rec/test/Makefile @@ -119,6 +119,10 @@ TESTSPEC_vxWorks = recordTestHarness.munch; epicsRunRecordTests TESTSPEC_RTEMS = recordTestHarness.boot; epicsRunRecordTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) +ifeq ($(T_A),RTEMS-pc386) +TESTPROD_RTEMS = $(TESTPROD_HOST) +TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) +endif include $(TOP)/configure/RULES From 1255cdc9eee919bf8e8ac9be7266fc23c9620203 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 15 Feb 2016 17:09:44 -0500 Subject: [PATCH 06/22] libCom/test: only run epicsUnitTest for host arch custom .plt won't use WINE or QEMU when necessary. --- src/libCom/test/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 0aba60e32..b8014a2ab 100755 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -15,11 +15,16 @@ PROD_SYS_LIBS_WIN32 += ws2_32 advapi32 user32 PROD_SRCS_RTEMS += rtemsTestData.c +ifeq ($(EPICS_HOST_ARCH),$(T_A)) +# skip except for host arch due to custom .plt + TESTPROD_HOST += epicsUnitTestTest epicsUnitTestTest_SRCS += epicsUnitTestTest.c # Not much point running this on vxWorks or RTEMS... TESTS += epicsUnitTestTest +endif + TESTPROD_HOST += epicsTypesTest epicsTypesTest_SRCS += epicsTypesTest.cpp testHarness_SRCS += epicsTypesTest.cpp From c8b60e0f1bcc8c4faf340fb283b61e96869aa0a5 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 29 Feb 2016 20:28:52 -0500 Subject: [PATCH 07/22] db/test: dbStressLock skip for RTEMS This test assumes that several threads with equal priority will all run eventually. This isn't true an UP target without time sliced scheduling (eg. RTEMS). --- src/ioc/db/test/dbStressLock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ioc/db/test/dbStressLock.c b/src/ioc/db/test/dbStressLock.c index 376587975..03a8e8b54 100644 --- a/src/ioc/db/test/dbStressLock.c +++ b/src/ioc/db/test/dbStressLock.c @@ -228,6 +228,11 @@ MAIN(dbStressTest) testPlan(80+nworkers*3); +#if defined(__rtems__) + testSkip(80+nworkers*3, "Test assumes time sliced preempting scheduling"); + return testDone(); +#endif + priv = callocMustSucceed(nworkers, sizeof(*priv), "no memory"); testDiag("lock set stress test"); From aace975de13fdd71472fd4aaeddb866d37b885e7 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 20 Jun 2015 09:05:28 -0400 Subject: [PATCH 08/22] RTEMS: probe for PCI varient of NE2000 NIC Provided by QEMU --- src/libCom/RTEMS/Makefile | 4 +++ src/libCom/RTEMS/ne2kpci.c | 58 ++++++++++++++++++++++++++++++ src/libCom/RTEMS/rtems_netconfig.c | 10 +++++- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/libCom/RTEMS/ne2kpci.c diff --git a/src/libCom/RTEMS/Makefile b/src/libCom/RTEMS/Makefile index 8652c669b..8d467b260 100644 --- a/src/libCom/RTEMS/Makefile +++ b/src/libCom/RTEMS/Makefile @@ -21,6 +21,10 @@ rtemsCom_SRCS += epicsRtemsInitHookPre.c rtemsCom_SRCS += epicsRtemsInitHookPost.c rtemsCom_SRCS += epicsMemFs.c +ifeq ($(T_A),RTEMS-pc386) +rtemsCom_SRCS += ne2kpci.c +endif + LIBRARY_RTEMS = rtemsCom include $(TOP)/configure/RULES diff --git a/src/libCom/RTEMS/ne2kpci.c b/src/libCom/RTEMS/ne2kpci.c new file mode 100644 index 000000000..909d885f1 --- /dev/null +++ b/src/libCom/RTEMS/ne2kpci.c @@ -0,0 +1,58 @@ +/*************************************************************************\ +* Copyright (c) 2015 Brookhaven Science Associates, as Operator of +* Brookhaven National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Wrapper around the ISA ne2000 driver to support detection of the PCI variant. + * Can be used with the ne2k_pci device provided by QEMU. + * + * eg. "qemu-system-i386 ... -net nic,model=ne2k_pci" + */ + +#include +#include +#include +#include +#include + +/* The plain ISA driver attach() + * which doesn't (can't?) do any test to see if + * the HW is really present + */ +extern int +rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach); + +int +rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach) +{ + uint8_t irq; + uint32_t bar0; + int B, D, F, ret; + printk("Probing for NE2000 on PCI (aka. Realtek 8029)\n"); + + if(pci_find_device(PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029, 0, &B, &D, &F)) + { + printk("Not found\n"); + return 0; + } + + printk("Found %d:%d.%d\n", B, D, F); + + ret = pci_read_config_dword(B, D, F, PCI_BASE_ADDRESS_0, &bar0); + ret|= pci_read_config_byte(B, D, F, PCI_INTERRUPT_LINE, &irq); + + if(ret || (bar0&PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_IO) + { + printk("Failed reading card config\n"); + return 0; + } + + config->irno = irq; + config->port = bar0&PCI_BASE_ADDRESS_IO_MASK; + + printk("Using port=0x%x irq=%u\n", (unsigned)config->port, config->irno); + + return rtems_ne_driver_attach(config, attach); +} diff --git a/src/libCom/RTEMS/rtems_netconfig.c b/src/libCom/RTEMS/rtems_netconfig.c index 832a6646b..d0c500c92 100644 --- a/src/libCom/RTEMS/rtems_netconfig.c +++ b/src/libCom/RTEMS/rtems_netconfig.c @@ -36,11 +36,19 @@ static struct rtems_bsdnet_ifconfig loopback_config = { * application directory and make the appropriate changes. */ #if defined(__i386__) + +extern int +rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach); +static struct rtems_bsdnet_ifconfig ne2k_driver_config = { + "ne2", /* name */ + rtems_ne2kpci_driver_attach, /* attach function */ + &loopback_config, /* link to next interface */ +}; extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int); static struct rtems_bsdnet_ifconfig fxp_driver_config = { "fxp1", /* name */ rtems_fxp_attach, /* attach function */ - &loopback_config, /* link to next interface */ + &ne2k_driver_config, /* link to next interface */ }; extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int); static struct rtems_bsdnet_ifconfig e3c509_driver_config = { From 6923ca9fdad24d618cb6dcf5d2e48e20ce298a2f Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 20 Jun 2015 11:57:43 -0400 Subject: [PATCH 09/22] RTEMS: conditional fixups for pc386 --- src/libCom/RTEMS/Makefile | 3 +++ src/libCom/RTEMS/rtems_init.c | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/libCom/RTEMS/Makefile b/src/libCom/RTEMS/Makefile index 8d467b260..2f12b7bf0 100644 --- a/src/libCom/RTEMS/Makefile +++ b/src/libCom/RTEMS/Makefile @@ -12,6 +12,9 @@ include $(TOP)/configure/CONFIG INC += epicsRtemsInitHooks.h INC += epicsMemFs.h +ifeq ($(RTEMS_QEMU_FIXUPS),YES) +rtems_init_CPPFLAGS += -DQEMU_FIXUPS +endif rtemsCom_SRCS += rtems_init.c rtemsCom_SRCS += rtems_config.c rtemsCom_SRCS += rtems_netconfig.c diff --git a/src/libCom/RTEMS/rtems_init.c b/src/libCom/RTEMS/rtems_init.c index 4e8298a29..7dbf2594f 100644 --- a/src/libCom/RTEMS/rtems_init.c +++ b/src/libCom/RTEMS/rtems_init.c @@ -33,6 +33,7 @@ #include #include +#include "epicsVersion.h" #include "epicsThread.h" #include "epicsTime.h" #include "epicsExit.h" @@ -46,6 +47,8 @@ #include "epicsRtemsInitHooks.h" +#define RTEMS_VERSION_INT VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, 0, 0) + /* * Prototypes for some functions not in header files */ @@ -695,3 +698,37 @@ Init (rtems_task_argument ignored) epicsThreadSleep(1.0); epicsExit(result); } + +#if defined(QEMU_FIXUPS) +/* Override some hooks (weak symbols) + * if BSP defaults aren't configured for running tests. + */ + + +/* Ensure that stdio goes to serial (so it can be captured) */ +#if defined(__i386__) && !USE_COM1_AS_CONSOLE +#include +extern int BSPPrintkPort; +void bsp_predriver_hook(void) +{ + BSPConsolePort = BSP_CONSOLE_PORT_COM1; + BSPPrintkPort = BSP_CONSOLE_PORT_COM1; +} +#endif + +/* reboot immediately when done. */ +#if defined(__i386__) && BSP_PRESS_KEY_FOR_RESET +void bsp_cleanup(void) +{ +#if RTEMS_VERSION_INT>=VERSION_INT(4,10,0,0) + void bsp_reset(); + bsp_reset(); +#else + rtemsReboot(); +#endif +} +#endif + +#endif /* QEMU_FIXUPS */ + +int cexpdebug __attribute__((weak)); From d5f74fe0062ebc86484c1a8fdbdc72524a46ba64 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 15 Feb 2017 20:40:22 -0500 Subject: [PATCH 10/22] rtems tests for pc386 --- configure/os/CONFIG_SITE.Common.RTEMS-pc386 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc386 b/configure/os/CONFIG_SITE.Common.RTEMS-pc386 index c772c44fc..85effbe96 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS-pc386 +++ b/configure/os/CONFIG_SITE.Common.RTEMS-pc386 @@ -1,3 +1,5 @@ # # Site-specific overrides for RTEMS-pc386 target # + +CROSS_COMPILER_RUNTEST_ARCHS += RTEMS-pc386 From e8b4f448ea1faaa2dada63bc3c340e9950354f34 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 24 Nov 2015 18:00:10 -0500 Subject: [PATCH 11/22] travis-ci: run tests with RTEMS pc386/qemu --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5079bff0c..743908764 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ env: - CMPLR=clang STATIC=YES - WINE=32 TEST=NO STATIC=YES - WINE=32 TEST=NO STATIC=NO - - RTEMS=4.10 TEST=NO - - RTEMS=4.9 TEST=NO + - RTEMS=4.10 TEST=YES + - RTEMS=4.9 TEST=YES addons: apt: packages: From dcb494b494674b330595599d53014f50b1236dd3 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 13 Mar 2018 16:40:01 -0700 Subject: [PATCH 12/22] rtemsttest generalize condition for individual tests --- ci/travis-build.sh | 1 + src/ioc/db/test/Makefile | 2 +- src/libCom/test/Makefile | 2 +- src/std/filters/test/Makefile | 2 +- src/std/rec/test/Makefile | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ci/travis-build.sh b/ci/travis-build.sh index ba752ac4a..f487fbb88 100644 --- a/ci/travis-build.sh +++ b/ci/travis-build.sh @@ -72,6 +72,7 @@ RTEMS_BASE=/home/travis/.cache/rtems${RTEMS}-i386 EOF cat << EOF >> configure/CONFIG_SITE CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386 +CROSS_COMPILER_RUNTEST_ARCHS+=RTEMS-pc386 EOF # find local qemu-system-i386 diff --git a/src/ioc/db/test/Makefile b/src/ioc/db/test/Makefile index baa381534..90ca9da35 100644 --- a/src/ioc/db/test/Makefile +++ b/src/ioc/db/test/Makefile @@ -184,7 +184,7 @@ TESTSPEC_vxWorks = dbTestHarness.munch; epicsRunDbTests TESTSPEC_RTEMS = dbTestHarness.boot; epicsRunDbTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) -ifeq ($(T_A),RTEMS-pc386) +ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),) TESTPROD_RTEMS = $(TESTPROD_HOST) TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) endif diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index b8014a2ab..a2ceb4ea4 100755 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -235,7 +235,7 @@ TESTSPEC_vxWorks = libComTestHarness.munch; epicsRunLibComTests TESTSPEC_RTEMS = libComTestHarness.boot; epicsRunLibComTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) -ifeq ($(T_A),RTEMS-pc386) +ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),) TESTPROD_RTEMS = $(TESTPROD_HOST) TESTSCRIPTS_RTEMS += $(filter-out epicsUnitTestTest.t, $(TESTS:%=%.t)) endif diff --git a/src/std/filters/test/Makefile b/src/std/filters/test/Makefile index 6442ba332..d6d9973f6 100644 --- a/src/std/filters/test/Makefile +++ b/src/std/filters/test/Makefile @@ -71,7 +71,7 @@ TESTSPEC_vxWorks = filterTestHarness.munch; epicsRunFilterTests TESTSPEC_RTEMS = filterTestHarness.boot; epicsRunFilterTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) -ifeq ($(T_A),RTEMS-pc386) +ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),) TESTPROD_RTEMS = $(TESTPROD_HOST) TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) endif diff --git a/src/std/rec/test/Makefile b/src/std/rec/test/Makefile index f5f9b4312..14e10946c 100644 --- a/src/std/rec/test/Makefile +++ b/src/std/rec/test/Makefile @@ -119,7 +119,7 @@ TESTSPEC_vxWorks = recordTestHarness.munch; epicsRunRecordTests TESTSPEC_RTEMS = recordTestHarness.boot; epicsRunRecordTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) -ifeq ($(T_A),RTEMS-pc386) +ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),) TESTPROD_RTEMS = $(TESTPROD_HOST) TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) endif From 65dec97f9ed98414c230c04624458b635dc6c74f Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 3 Dec 2017 10:22:19 -0600 Subject: [PATCH 13/22] use new RTEMS build --- ci/travis-build.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ci/travis-build.sh b/ci/travis-build.sh index f487fbb88..0b592228c 100644 --- a/ci/travis-build.sh +++ b/ci/travis-build.sh @@ -62,13 +62,13 @@ if [ -n "$RTEMS" ] then echo "Cross RTEMS${RTEMS} for pc386" install -d /home/travis/.cache - curl -L "https://github.com/mdavidsaver/rsb/releases/download/travis-20160306-2/rtems${RTEMS}-i386-trusty-20190306-2.tar.gz" \ - | tar -C /home/travis/.cache -xj + curl -L "https://github.com/mdavidsaver/rsb/releases/download/20171203-${RTEMS}/i386-rtems${RTEMS}-trusty-20171203-${RTEMS}.tar.bz2" \ + | tar -C / -xmj sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' configure/os/CONFIG_SITE.Common.RTEMS cat << EOF >> configure/os/CONFIG_SITE.Common.RTEMS RTEMS_VERSION=$RTEMS -RTEMS_BASE=/home/travis/.cache/rtems${RTEMS}-i386 +RTEMS_BASE=/home/travis/.rtems EOF cat << EOF >> configure/CONFIG_SITE CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386 @@ -76,7 +76,6 @@ CROSS_COMPILER_RUNTEST_ARCHS+=RTEMS-pc386 EOF # find local qemu-system-i386 - export PATH="$HOME/.cache/qemu/usr/bin:$PATH" echo -n "Using QEMU: " type qemu-system-i386 || echo "Missing qemu" EXTRA=RTEMS_QEMU_FIXUPS=YES From 83b17d5061d9f6008581a59ff189ec5eeb43e847 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 22 Oct 2017 20:00:37 -0500 Subject: [PATCH 14/22] travis-ci: remove unused --- .travis.yml | 1 - ci/travis-build.sh | 9 --------- ci/travis-prepare.sh | 40 ---------------------------------------- 3 files changed, 50 deletions(-) delete mode 100644 ci/travis-prepare.sh diff --git a/.travis.yml b/.travis.yml index 743908764..f8b11534f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,5 +28,4 @@ addons: cache: directories: - $HOME/.cache -install: sh ci/travis-prepare.sh &2 - exit 1 -} - -CURDIR="$PWD" - -QDIR="$HOME/.cache/qemu" - -if [ -n "$RTEMS" -a "$TEST" = "YES" ] -then - git clone --quiet --branch vme --depth 10 https://github.com/mdavidsaver/qemu.git "$HOME/.build/qemu" - cd "$HOME/.build/qemu" - - HEAD=`git log -n1 --pretty=format:%H` - echo "HEAD revision $HEAD" - - [ -e "$HOME/.cache/qemu/built" ] && BUILT=`cat "$HOME/.cache/qemu/built"` - echo "Cached revision $BUILT" - - if [ "$HEAD" != "$BUILT" ] - then - echo "Building QEMU" - git submodule --quiet update --init - - install -d "$HOME/.build/qemu/build" - cd "$HOME/.build/qemu/build" - - "$HOME/.build/qemu/configure" --prefix="$HOME/.cache/qemu/usr" --target-list=i386-softmmu --disable-werror - make -j2 - make install - - echo "$HEAD" > "$HOME/.cache/qemu/built" - fi -fi - -cd "$CURDIR" From ae5122759d9cc7d4560fdccbc91cefc66cf9b060 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 5 Sep 2018 09:04:14 +0200 Subject: [PATCH 15/22] travis-ci: install qemu --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f8b11534f..9b092e0fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ addons: - flex - texinfo - install-info + - qemu-system-x86 cache: directories: - $HOME/.cache From 3c607d903445035d0f8189d22cd4820389772541 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 24 Oct 2018 14:19:18 -0500 Subject: [PATCH 16/22] Require RTEMS_BSP to be set in CONFIG.Common.RTEMS- This is needed to allow multiple targets to be built against the same RTEMS BSP, allowing e.g. -qemu and -gesys targets. --- configure/os/CONFIG.Common.RTEMS | 2 +- configure/os/CONFIG.Common.RTEMS-at91rm9200ek | 3 ++- configure/os/CONFIG.Common.RTEMS-beatnik | 1 + configure/os/CONFIG.Common.RTEMS-gen68360 | 3 ++- configure/os/CONFIG.Common.RTEMS-mcp750 | 3 ++- configure/os/CONFIG.Common.RTEMS-mvme167 | 3 ++- configure/os/CONFIG.Common.RTEMS-mvme2100 | 1 + configure/os/CONFIG.Common.RTEMS-mvme2700 | 1 + configure/os/CONFIG.Common.RTEMS-mvme3100 | 1 + configure/os/CONFIG.Common.RTEMS-mvme5500 | 1 + configure/os/CONFIG.Common.RTEMS-pc386 | 3 ++- configure/os/CONFIG.Common.RTEMS-psim | 3 ++- configure/os/CONFIG.Common.RTEMS-uC5282 | 1 + 13 files changed, 19 insertions(+), 7 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 9650ae255..2624f79e5 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -29,7 +29,7 @@ endif #------------------------------------------------------- # Pick up the RTEMS tool/path definitions from the RTEMS BSP directory. -include $(RTEMS_BASE)/$(RTEMS_TARGET_CPU)-rtems$(RTEMS_VERSION)/$(subst RTEMS-,,$(T_A))/Makefile.inc +include $(RTEMS_BASE)/$(RTEMS_TARGET_CPU)-rtems$(RTEMS_VERSION)/$(RTEMS_BSP)/Makefile.inc include $(RTEMS_CUSTOM) include $(CONFIG.CC) diff --git a/configure/os/CONFIG.Common.RTEMS-at91rm9200ek b/configure/os/CONFIG.Common.RTEMS-at91rm9200ek index 6f5f97732..735c07bb5 100644 --- a/configure/os/CONFIG.Common.RTEMS-at91rm9200ek +++ b/configure/os/CONFIG.Common.RTEMS-at91rm9200ek @@ -9,5 +9,6 @@ # # All RTEMS targets use the same Makefile fragment # -RTEMS_TARGET_CPU=arm +RTEMS_BSP = at91rm9200ek +RTEMS_TARGET_CPU = arm include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-beatnik b/configure/os/CONFIG.Common.RTEMS-beatnik index 00080e7fd..2c0c0cb10 100644 --- a/configure/os/CONFIG.Common.RTEMS-beatnik +++ b/configure/os/CONFIG.Common.RTEMS-beatnik @@ -5,6 +5,7 @@ # All RTEMS targets use the same Makefile fragment # EXE = .elf +RTEMS_BSP = beatnik RTEMS_TARGET_CPU = powerpc GNU_TARGET = powerpc-rtems ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL diff --git a/configure/os/CONFIG.Common.RTEMS-gen68360 b/configure/os/CONFIG.Common.RTEMS-gen68360 index a6663afc2..0a8a6e85e 100644 --- a/configure/os/CONFIG.Common.RTEMS-gen68360 +++ b/configure/os/CONFIG.Common.RTEMS-gen68360 @@ -5,5 +5,6 @@ # # All RTEMS targets use the same Makefile fragment # -RTEMS_TARGET_CPU=m68k +RTEMS_BSP = gen68360 +RTEMS_TARGET_CPU = m68k include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-mcp750 b/configure/os/CONFIG.Common.RTEMS-mcp750 index d834ad9ec..035e6eb36 100644 --- a/configure/os/CONFIG.Common.RTEMS-mcp750 +++ b/configure/os/CONFIG.Common.RTEMS-mcp750 @@ -5,5 +5,6 @@ # # All RTEMS targets use the same Makefile fragment # -RTEMS_TARGET_CPU=ppc +RTEMS_BSP = mcp750 +RTEMS_TARGET_CPU = ppc include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-mvme167 b/configure/os/CONFIG.Common.RTEMS-mvme167 index a6663afc2..3651f966f 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme167 +++ b/configure/os/CONFIG.Common.RTEMS-mvme167 @@ -5,5 +5,6 @@ # # All RTEMS targets use the same Makefile fragment # -RTEMS_TARGET_CPU=m68k +RTEMS_BSP = mvme167 +RTEMS_TARGET_CPU = m68k include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-mvme2100 b/configure/os/CONFIG.Common.RTEMS-mvme2100 index 687af2374..c26bd783a 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme2100 +++ b/configure/os/CONFIG.Common.RTEMS-mvme2100 @@ -5,6 +5,7 @@ # All RTEMS targets use the same Makefile fragment # EXE = .elf +RTEMS_BSP = mvme2100 RTEMS_TARGET_CPU = powerpc GNU_TARGET = powerpc-rtems ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL diff --git a/configure/os/CONFIG.Common.RTEMS-mvme2700 b/configure/os/CONFIG.Common.RTEMS-mvme2700 index f45e321c4..a01aa9f6a 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme2700 +++ b/configure/os/CONFIG.Common.RTEMS-mvme2700 @@ -1,6 +1,7 @@ # # Author: Matt Rippa # +RTEMS_BSP = mvme2700 RTEMS_TARGET_CPU = powerpc ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL ARCH_DEP_CFLAGS += -DHAVE_PPCBUG diff --git a/configure/os/CONFIG.Common.RTEMS-mvme3100 b/configure/os/CONFIG.Common.RTEMS-mvme3100 index cd9416ce7..b71e8b60e 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme3100 +++ b/configure/os/CONFIG.Common.RTEMS-mvme3100 @@ -5,6 +5,7 @@ # All RTEMS targets use the same Makefile fragment # EXE = .elf +RTEMS_BSP = mvme3100 RTEMS_TARGET_CPU = powerpc GNU_TARGET = powerpc-rtems ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL diff --git a/configure/os/CONFIG.Common.RTEMS-mvme5500 b/configure/os/CONFIG.Common.RTEMS-mvme5500 index 0c05b76a8..a10179e5a 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme5500 +++ b/configure/os/CONFIG.Common.RTEMS-mvme5500 @@ -5,6 +5,7 @@ # All RTEMS targets use the same Makefile fragment # EXE = .elf +RTEMS_BSP = mvme5500 RTEMS_TARGET_CPU = powerpc GNU_TARGET = powerpc-rtems ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL diff --git a/configure/os/CONFIG.Common.RTEMS-pc386 b/configure/os/CONFIG.Common.RTEMS-pc386 index b3150cc66..290d26f2c 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386 +++ b/configure/os/CONFIG.Common.RTEMS-pc386 @@ -5,7 +5,8 @@ # # All RTEMS targets use the same Makefile fragment # -RTEMS_TARGET_CPU=i386 +RTEMS_BSP = pc386 +RTEMS_TARGET_CPU = i386 MUNCH_SUFFIX = .boot MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) diff --git a/configure/os/CONFIG.Common.RTEMS-psim b/configure/os/CONFIG.Common.RTEMS-psim index 230d72e1f..58ad72852 100644 --- a/configure/os/CONFIG.Common.RTEMS-psim +++ b/configure/os/CONFIG.Common.RTEMS-psim @@ -5,5 +5,6 @@ # # All RTEMS targets use the same Makefile fragment # -RTEMS_TARGET_CPU=ppc +RTEMS_BSP = psim +RTEMS_TARGET_CPU = ppc include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-uC5282 b/configure/os/CONFIG.Common.RTEMS-uC5282 index 9c6a58d33..30aabf5ed 100644 --- a/configure/os/CONFIG.Common.RTEMS-uC5282 +++ b/configure/os/CONFIG.Common.RTEMS-uC5282 @@ -5,6 +5,7 @@ # # All RTEMS targets use the same Makefile fragment # +RTEMS_BSP = uC5282 RTEMS_TARGET_CPU = m68k ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL From 00ee7bf7d3618c748491c88742c011a8353abeba Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 24 Oct 2018 14:27:15 -0500 Subject: [PATCH 17/22] Add RTEMS-pc368-qemu target, use in Travis-CI builds --- ci/travis-build.sh | 5 ++--- configure/os/CONFIG.Common.RTEMS-pc386-qemu | 11 +++++++++++ configure/os/CONFIG_SITE.Common.RTEMS-pc386 | 5 ----- configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu | 9 +++++++++ src/libCom/RTEMS/Makefile | 2 +- src/tools/makeTestfile.pl | 2 +- 6 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 configure/os/CONFIG.Common.RTEMS-pc386-qemu delete mode 100644 configure/os/CONFIG_SITE.Common.RTEMS-pc386 create mode 100644 configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu diff --git a/ci/travis-build.sh b/ci/travis-build.sh index e15d7f6b4..f7443267b 100644 --- a/ci/travis-build.sh +++ b/ci/travis-build.sh @@ -62,14 +62,13 @@ RTEMS_VERSION=$RTEMS RTEMS_BASE=/home/travis/.rtems EOF cat << EOF >> configure/CONFIG_SITE -CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386 -CROSS_COMPILER_RUNTEST_ARCHS+=RTEMS-pc386 +CROSS_COMPILER_TARGET_ARCHS += RTEMS-pc386-qemu +CROSS_COMPILER_RUNTEST_ARCHS += RTEMS-pc386-qemu EOF # find local qemu-system-i386 echo -n "Using QEMU: " type qemu-system-i386 || echo "Missing qemu" - EXTRA=RTEMS_QEMU_FIXUPS=YES fi make -j2 $EXTRA diff --git a/configure/os/CONFIG.Common.RTEMS-pc386-qemu b/configure/os/CONFIG.Common.RTEMS-pc386-qemu new file mode 100644 index 000000000..684f01a19 --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-pc386-qemu @@ -0,0 +1,11 @@ +# CONFIG.Common.RTEMS-pc386-qemu +# +# Definitions for the RTEMS-pc386-qemu target +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc386-qemu +# +#------------------------------------------------------- + +# Include definitions from RTEMS-pc386 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc386 + +RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc386 b/configure/os/CONFIG_SITE.Common.RTEMS-pc386 deleted file mode 100644 index 85effbe96..000000000 --- a/configure/os/CONFIG_SITE.Common.RTEMS-pc386 +++ /dev/null @@ -1,5 +0,0 @@ -# -# Site-specific overrides for RTEMS-pc386 target -# - -CROSS_COMPILER_RUNTEST_ARCHS += RTEMS-pc386 diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu b/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu new file mode 100644 index 000000000..027dcf4ab --- /dev/null +++ b/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu @@ -0,0 +1,9 @@ +# CONFIG_SITE.Common.RTEMS-pc386-qemu +# +# Site-specific overrides for the RTEMS-pc386-qemu target +# + +# If you're building this architecture you _probably_ want to +# run the tests for it under QEMU, but if not you can turn +# them off here by commenting out this line: +CROSS_COMPILER_RUNTEST_ARCHS += RTEMS-pc386-qemu diff --git a/src/libCom/RTEMS/Makefile b/src/libCom/RTEMS/Makefile index 2f12b7bf0..22a92733c 100644 --- a/src/libCom/RTEMS/Makefile +++ b/src/libCom/RTEMS/Makefile @@ -24,7 +24,7 @@ rtemsCom_SRCS += epicsRtemsInitHookPre.c rtemsCom_SRCS += epicsRtemsInitHookPost.c rtemsCom_SRCS += epicsMemFs.c -ifeq ($(T_A),RTEMS-pc386) +ifeq ($(RTEMS_BSP),pc386) rtemsCom_SRCS += ne2kpci.c endif diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 73f522034..fb431fe7a 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -37,7 +37,7 @@ if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { $exec = "wine64 $exe"; # Run pc386 test harness w/ QEMU -} elsif( $TA =~ /^RTEMS-pc386$/ ) { +} elsif( $TA =~ /^RTEMS-pc386-qemu$/ ) { $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=ne2k_pci -net user,restrict=yes -kernel $exe"; # Explicitly fail for other RTEMS targets From 77bdea22f88cd56a82ce9d49e8884e9f0485dc6e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 24 Oct 2018 14:59:24 -0500 Subject: [PATCH 18/22] T_A can never contain spaces --- configure/RULES_BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index 5d335c126..0d7793e56 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -380,7 +380,7 @@ endif # Generate a perl program to exec the real test binary. %.t: %$(EXE) $(TOOLS)/makeTestfile.pl @$(RM) $@ - $(PERL) $(TOOLS)/makeTestfile.pl "$(T_A)" $(EPICS_HOST_ARCH) $@ $< + $(PERL) $(TOOLS)/makeTestfile.pl $(T_A) $(EPICS_HOST_ARCH) $@ $< #--------------------------------------------------------------- # Generate header with version number from VCS From ab59c97f4b9f574d8f49c67334cee3551ebcb7fc Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 24 Oct 2018 14:59:48 -0500 Subject: [PATCH 19/22] Minor Perl tidying up --- src/tools/makeTestfile.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index fb431fe7a..7d298768f 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -42,7 +42,7 @@ if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { # Explicitly fail for other RTEMS targets } elsif( $TA =~ /^RTEMS-/ ) { - die "I don't know how to run tests for $TA on $HA"; + die "$0: I don't know how to create scripts for testing $TA on $HA\n"; } else { $exec = "./$exe"; @@ -51,7 +51,7 @@ if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { open(my $OUT, '>', $target) or die "Can't create $target: $!\n"; print $OUT < Date: Wed, 24 Oct 2018 15:25:05 -0500 Subject: [PATCH 20/22] Don't require older RTEMS arch's to set RTEMS_BSP This uses the old rules for RTEMS target architecture names to work out what the value of RTEMS_BSP should be if it isn't set. Targets had to be named RTEMS-$(RTEMS_BSP) in previous releases. With this change out-of-tree target configuration files should still work, but they can't be used to create sub-architectures without first setting RTEMS_BSP in their CONFIG.Common. file. --- configure/os/CONFIG.Common.RTEMS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 2624f79e5..2ab22b4fe 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -27,6 +27,10 @@ ifneq ($(CONFIG),$(TOP)/configure) -include $(TOP)/configure/CONFIG_SITE.Common.RTEMS endif +#-------------------------------------------------- +# Set RTEMS_BSP from T_A if not already done +RTEMS_BSP ?= $(subst RTEMS-,,$(T_A)) + #------------------------------------------------------- # Pick up the RTEMS tool/path definitions from the RTEMS BSP directory. include $(RTEMS_BASE)/$(RTEMS_TARGET_CPU)-rtems$(RTEMS_VERSION)/$(RTEMS_BSP)/Makefile.inc From 03b8257d7183491df4d6c4b5991411d0f1bc4a73 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 24 Oct 2018 16:04:02 -0500 Subject: [PATCH 21/22] Release Notes for the rtems-test branch --- documentation/RELEASE_NOTES.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 111c604d3..2c42fa63d 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -17,6 +17,33 @@ --> +

RTEMS build configuration update, running tests under QEMU

+ +

This release includes the ability to run the EPICS unit tests built for a +special version of the RTEMS-pc386 target architecture on systems that have an +appropriate QEMU emulator installed (qemu-system-i386). It is also now +possible to create sub-architectures of RTEMS targets, whereas previously the +EPICS target architecture name had to be RTEMS-$(RTEMS_BSP).

+ +

The new target RTEMS-pc386-qemu builds binaries that can be run in +the qemu-system-i386 PC System emulator. This target is a derivative of +the original RTEMS-pc386 target but with additional software to build +an in-memory file-system, and some minor modifications to allow the unit tests +to work properly under QEMU. When this target is enabled, building any of the +make targets that cause the built-in self-tests to be run (such as +make runtests) will also run the tests for RTEMS using QEMU.

+ +

To allow the new 3-component RTEMS target name, the EPICS build system for +RTEMS was modified to allow a configure/os/CONFIG.Common.<arch> +file to set the RTEMS_BSP variable to inform the build what RTEMS BSP +to use. Previously this was inferred from the value of the T_A make +variable, but that prevents having multiple EPICS targets that build against the +same BSP. All the included RTEMS target configuration files have been updated; +build configuration files for out-of-tree RTEMS targets will continue to work as +the original rules are used to set RTEMS_BSP if it hasn't been set when +needed.

+ +

Changes made between 3.16.0.1 and 3.16.1

IOC Database Support for 64-bit integers

From a81c3503d26df79b3a437f6dde2b60015e6ffb12 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 25 Oct 2018 11:15:57 -0500 Subject: [PATCH 22/22] Fix MUNCH_CMD for RTEMS-pc386 with parallel builds --- configure/os/CONFIG.Common.RTEMS-pc386 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS-pc386 b/configure/os/CONFIG.Common.RTEMS-pc386 index 290d26f2c..fc962d013 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386 +++ b/configure/os/CONFIG.Common.RTEMS-pc386 @@ -11,10 +11,10 @@ RTEMS_TARGET_CPU = i386 MUNCH_SUFFIX = .boot MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) define MUNCH_CMD - $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary -R .comment -S $< temp.bin + $(RM) $*.bin + $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary -R .comment -S $< $*.bin $(BIN2BOOT) $@ 0x00097E00 \ - $(PROJECT_RELEASE)/lib/start16.bin 0x00097C00 0 temp.bin 0x00100000 0 - rm -f temp.bin + $(PROJECT_RELEASE)/lib/start16.bin 0x00097C00 0 $*.bin 0x00100000 0 endef include $(CONFIG)/os/CONFIG.Common.RTEMS