Merge lp:~epics-core/epics-base/test-rtems-w-qemu into lp:~epics-core/epics-base/3.16

Proposed by mdavidsaver
Status: Work in progress
Proposed branch: lp:~epics-core/epics-base/test-rtems-w-qemu
Merge into: lp:~epics-core/epics-base/3.16
Diff against target: 566 lines (+337/-6)
16 files modified
configure/RULES_BUILD (+1/-1)
src/ioc/db/test/Makefile (+8/-0)
src/ioc/db/test/dbStressLock.c (+5/-0)
src/libCom/RTEMS/Makefile (+2/-0)
src/libCom/RTEMS/epicsMemFs.c (+110/-0)
src/libCom/RTEMS/epicsMemFs.h (+24/-0)
src/libCom/RTEMS/epicsRtemsInitHooks.h (+2/-0)
src/libCom/RTEMS/rtems_init.c (+30/-1)
src/libCom/misc/testMain.h (+7/-1)
src/libCom/test/Makefile (+11/-0)
src/libCom/test/rtemsTestData.c (+6/-0)
src/std/filters/test/Makefile (+9/-0)
src/std/rec/test/Makefile (+9/-0)
src/tools/Makefile (+1/-0)
src/tools/epicsMakeMemFs.pl (+83/-0)
src/tools/makeTestfile.pl (+29/-3)
To merge this branch: bzr merge lp:~epics-core/epics-base/test-rtems-w-qemu
Reviewer Review Type Date Requested Status
EPICS Core Developers Pending
Review via email: mp+286116@code.launchpad.net

Description of the change

Enable easy execution of RTEMS-pc386 test harnesses with QEMU (and windows on *nix w/ WINE).

Avoid the usual problem of NIC support (and the rtems 4.10 tftp bug) by including test data file in the test executables. Test files are encoded as C source using a script. Files are extracted into memory on boot.

For RTEMS build both the combined test harness and individual test executables.

Teach makeTestfile.pl to generate .t files which call qemu or wine based on T_A and EPICS_HOST_ARCH.

Includes some additions to rtems_init.c to allow conditional bypass of NFS mounting.

To post a comment you must log in.
Revision history for this message
mdavidsaver (mdavidsaver) wrote :

I don't consider this a priority for 3.16.0.1. I'm publishing this now because it's handy to be able to 'make runtests' for rtems and windows cross targets.

12719. By mdavidsaver

db/test: dbStressLock skip for RTEMS

This test assumes that several threads with
equal priority will all run eventually.
This isn't turn an UP target without
time sliced scheduling.

12720. By mdavidsaver

rec/test: rtems build self contained tests and run individually

12721. By mdavidsaver

rec/test: add missing TESTFILES

12722. By mdavidsaver

rec/test: asTest fixup rtems test harness

Since this test has device support it must appear in a
DLL for windows dynamic builds.
However, the rRDD function is in the executable,
and not accessible here. So use iocsh.
For rtems/vxworks the test harness clears
iocsh registrations, so iocsh can't work here.

Revision history for this message
Andrew Johnson (anj) wrote :

Uses weak symbols -- issue with uC5282 BSP target, which is 68K family.

Revision history for this message
Andrew Johnson (anj) wrote :

Cancel that, the .o files for uC5282 are ELF.

Revision history for this message
mdavidsaver (mdavidsaver) wrote :

There is additional work on https://github.com/mdavidsaver/epics-base/tree/rtemstest which still needs to migrate to LP. I also need to see how this fits with work by Heinz on more recent rtems versions.

Unmerged revisions

12722. By mdavidsaver

rec/test: asTest fixup rtems test harness

Since this test has device support it must appear in a
DLL for windows dynamic builds.
However, the rRDD function is in the executable,
and not accessible here. So use iocsh.
For rtems/vxworks the test harness clears
iocsh registrations, so iocsh can't work here.

12721. By mdavidsaver

rec/test: add missing TESTFILES

12720. By mdavidsaver

rec/test: rtems build self contained tests and run individually

12719. By mdavidsaver

db/test: dbStressLock skip for RTEMS

This test assumes that several threads with
equal priority will all run eventually.
This isn't turn an UP target without
time sliced scheduling.

12718. By mdavidsaver

libCom/test: only run epicsUnitTest for host arch

custom .plt won't use WINE or QEMU when necessary.

12717. By mdavidsaver

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

12716. By mdavidsaver

RTEMS: build self contained test harness

Test data stub as a separate file to allow
linking into test harness and individual tests.

12715. By mdavidsaver

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.

12714. By mdavidsaver

src/tools: teach makeTestfile about WINE and QEMU

Teach makeTestfile host to run test for some cross built
targets.

12713. By mdavidsaver

libCom/misc: testMain for RTEMS give weak alias for main()

Allows tests to be linked separately or in a common test harness

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure/RULES_BUILD'
2--- configure/RULES_BUILD 2016-02-27 00:16:26 +0000
3+++ configure/RULES_BUILD 2016-03-01 02:02:15 +0000
4@@ -344,7 +344,7 @@
5 # Generate a perl program to exec the real test binary.
6 %.t: %$(EXE) $(TOOLS)/makeTestfile.pl
7 @$(RM) $@
8- $(PERL) $(TOOLS)/makeTestfile.pl $@ $<
9+ $(PERL) $(TOOLS)/makeTestfile.pl "$(T_A)" $(EPICS_HOST_ARCH) $@ $<
10
11 #---------------------------------------------------------------
12 # Generate header with version number from VCS
13
14=== modified file 'src/ioc/db/test/Makefile'
15--- src/ioc/db/test/Makefile 2016-02-29 19:48:18 +0000
16+++ src/ioc/db/test/Makefile 2016-03-01 02:02:15 +0000
17@@ -157,6 +157,8 @@
18 dbTestHarness_SRCS += $(testHarness_SRCS)
19 dbTestHarness_SRCS_RTEMS += rtemsTestHarness.c
20
21+PROD_SRCS_RTEMS += rtemsTestData.c
22+
23 PROD_vxWorks = dbTestHarness
24 PROD_RTEMS = dbTestHarness
25
26@@ -164,6 +166,10 @@
27 TESTSPEC_RTEMS = dbTestHarness.boot; epicsRunDbTests
28
29 TESTSCRIPTS_HOST += $(TESTS:%=%.t)
30+ifeq ($(T_A),RTEMS-pc386)
31+TESTPROD_RTEMS = $(TESTPROD_HOST)
32+TESTSCRIPTS_RTEMS += $(TESTS:%=%.t)
33+endif
34
35 include $(TOP)/configure/RULES
36
37@@ -175,3 +181,5 @@
38 scanIoTest$(DEP): $(COMMON_DIR)/xRecord.h
39 xRecord$(DEP): $(COMMON_DIR)/xRecord.h
40
41+rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl
42+ $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES)
43
44=== modified file 'src/ioc/db/test/dbStressLock.c'
45--- src/ioc/db/test/dbStressLock.c 2015-09-08 13:52:52 +0000
46+++ src/ioc/db/test/dbStressLock.c 2016-03-01 02:02:15 +0000
47@@ -230,6 +230,11 @@
48
49 testPlan(80+nworkers*3);
50
51+#if defined(__rtems__)
52+ testSkip(80+nworkers*3, "Test assumes time sliced preempting scheduling");
53+ return testDone();
54+#endif
55+
56 priv = callocMustSucceed(nworkers, sizeof(*priv), "no memory");
57
58 testDiag("lock set stress test");
59
60=== modified file 'src/libCom/RTEMS/Makefile'
61--- src/libCom/RTEMS/Makefile 2011-11-14 23:42:50 +0000
62+++ src/libCom/RTEMS/Makefile 2016-03-01 02:02:15 +0000
63@@ -10,6 +10,7 @@
64 include $(TOP)/configure/CONFIG
65
66 INC += epicsRtemsInitHooks.h
67+INC += epicsMemFs.h
68
69 rtemsCom_SRCS += rtems_init.c
70 rtemsCom_SRCS += rtems_config.c
71@@ -18,6 +19,7 @@
72 rtemsCom_SRCS += setBootConfigFromNVRAM.c
73 rtemsCom_SRCS += epicsRtemsInitHookPre.c
74 rtemsCom_SRCS += epicsRtemsInitHookPost.c
75+rtemsCom_SRCS += epicsMemFs.c
76
77 LIBRARY_RTEMS = rtemsCom
78
79
80=== added file 'src/libCom/RTEMS/epicsMemFs.c'
81--- src/libCom/RTEMS/epicsMemFs.c 1970-01-01 00:00:00 +0000
82+++ src/libCom/RTEMS/epicsMemFs.c 2016-03-01 02:02:15 +0000
83@@ -0,0 +1,110 @@
84+/*************************************************************************\
85+* Copyright (c) 2014 Brookhaven National Laboratory.
86+* EPICS BASE is distributed subject to a Software License Agreement found
87+* in file LICENSE that is included with this distribution.
88+\*************************************************************************/
89+
90+#include <stdlib.h>
91+#include <stdio.h>
92+#include <errno.h>
93+
94+#include <unistd.h>
95+#include <sys/stat.h>
96+#include <sys/types.h>
97+#include <fcntl.h>
98+
99+#include "epicsMemFs.h"
100+
101+#ifndef PATH_MAX
102+# define PATH_MAX 100
103+#endif
104+
105+int epicsMemFsLoad(const epicsMemFS *fs)
106+{
107+ char initdir[PATH_MAX];
108+ const epicsMemFile * const *fileptr = fs->files;
109+
110+ if(getcwd(initdir, sizeof(initdir)-1)==NULL) {
111+ perror("getcwd");
112+ return errno;
113+ }
114+ initdir[sizeof(initdir)-1] = '\0';
115+
116+ for(;*fileptr; fileptr++) {
117+ const epicsMemFile *curfile = *fileptr;
118+ int fd;
119+ ssize_t ret;
120+ size_t sofar;
121+ const char * const *dir = curfile->directory;
122+ /* jump back to the root each time,
123+ * slow but simple.
124+ */
125+ if(chdir(initdir)) {
126+ perror("chdir");
127+ return errno;
128+ }
129+
130+ printf("-> /");
131+
132+ /* traverse directory tree, creating as necessary */
133+ for(;*dir; dir++) {
134+ int ret;
135+ if(**dir=='.') continue; /* ignore '.' and '..' */
136+ printf("%s/", *dir);
137+ ret = chdir(*dir);
138+ if(ret==-1 && errno==ENOENT) {
139+ /* this directory doesn't exist */
140+ if(mkdir(*dir,0744)==-1) {
141+ printf("\n");
142+ perror("mkdir");
143+ return errno;
144+ }
145+ if(chdir(*dir)==-1) {
146+ printf("\n");
147+ perror("chdir2");
148+ return errno;
149+ }
150+ } else if(ret==-1) {
151+ printf("\n");
152+ perror("chdir1");
153+ return errno;
154+ }
155+ }
156+
157+ /* no file name creates an empty directory */
158+ if(!curfile->name) {
159+ printf("\n");
160+ continue;
161+ }
162+ printf("%s", curfile->name);
163+
164+ /* create or overwrite */
165+ fd = open(curfile->name, O_WRONLY|O_CREAT|O_TRUNC, 0644);
166+
167+ if(fd==-1) {
168+ printf("\n");
169+ perror("open");
170+ return errno;
171+ }
172+
173+ sofar = 0;
174+
175+ while(sofar<curfile->size) {
176+ ret = write(fd, curfile->data+sofar, curfile->size-sofar);
177+ if(ret<=0) {
178+ printf("\n");
179+ perror("write");
180+ return errno;
181+ }
182+ sofar += ret;
183+ }
184+
185+ close(fd);
186+ printf(" - ok\n");
187+ }
188+
189+ if(chdir(initdir))
190+ perror("chdir");
191+
192+ return 0;
193+}
194
195=== added file 'src/libCom/RTEMS/epicsMemFs.h'
196--- src/libCom/RTEMS/epicsMemFs.h 1970-01-01 00:00:00 +0000
197+++ src/libCom/RTEMS/epicsMemFs.h 2016-03-01 02:02:15 +0000
198@@ -0,0 +1,24 @@
199+/*************************************************************************\
200+* Copyright (c) 2014 Brookhaven National Laboratory.
201+* EPICS BASE is distributed subject to a Software License Agreement found
202+* in file LICENSE that is included with this distribution.
203+\*************************************************************************/
204+#ifndef EPICSMEMFS_H
205+#define EPICSMEMFS_H
206+
207+#include <stdlib.h>
208+
209+typedef struct {
210+ const char * const *directory; /* NULL terminated list of directories */
211+ const char *name; /* file name */
212+ const char *data; /* file contents */
213+ size_t size; /* size of file contents in bytes */
214+} epicsMemFile;
215+
216+typedef struct {
217+ const epicsMemFile * const *files;
218+} epicsMemFS;
219+
220+int epicsMemFsLoad(const epicsMemFS *fs);
221+
222+#endif // EPICSMEMFS_H
223
224=== modified file 'src/libCom/RTEMS/epicsRtemsInitHooks.h'
225--- src/libCom/RTEMS/epicsRtemsInitHooks.h 2010-11-17 22:55:22 +0000
226+++ src/libCom/RTEMS/epicsRtemsInitHooks.h 2016-03-01 02:02:15 +0000
227@@ -22,3 +22,5 @@
228 */
229 int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config);
230 int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config);
231+/* Return 0 if local file system was setup, or non-zero (will fall back to network */
232+int epicsRtemsMountLocalFilesystem(char **argv);
233
234=== modified file 'src/libCom/RTEMS/rtems_init.c'
235--- src/libCom/RTEMS/rtems_init.c 2016-02-15 17:29:22 +0000
236+++ src/libCom/RTEMS/rtems_init.c 2016-03-01 02:02:15 +0000
237@@ -43,6 +43,7 @@
238 #include "osiUnistd.h"
239 #include "iocsh.h"
240 #include "osdTime.h"
241+#include "epicsMemFs.h"
242
243 #include "epicsRtemsInitHooks.h"
244
245@@ -139,6 +140,31 @@
246 # include <rtems/tftp.h>
247 #endif
248
249+const epicsMemFS *epicsRtemsFSImage __attribute__((weak));
250+const epicsMemFS *epicsRtemsFSImage = (void*)&epicsRtemsFSImage;
251+
252+/* hook to allow app specific FS setup */
253+int
254+epicsRtemsMountLocalFilesystem(char **argv) __attribute__((weak));
255+int
256+epicsRtemsMountLocalFilesystem(char **argv)
257+{
258+ if(epicsRtemsFSImage==(void*)&epicsRtemsFSImage)
259+ return -1; /* no FS image provided. */
260+ else if(epicsRtemsFSImage==NULL)
261+ return 0; /* no FS image provided, but none is needed. */
262+ else {
263+ printf("***** Using compiled in file data *****\n");
264+ if (epicsMemFsLoad(epicsRtemsFSImage) != 0) {
265+ printf("Can't unpack tar filesystem\n");
266+ return -1;
267+ } else {
268+ argv[1] = "/";
269+ return 0;
270+ }
271+ }
272+}
273+
274 static int
275 initialize_local_filesystem(char **argv)
276 {
277@@ -147,7 +173,9 @@
278 extern char _FlashSize[] __attribute__((weak));
279
280 argv[0] = rtems_bsdnet_bootp_boot_file_name;
281- if (_FlashSize && (_DownloadLocation || _FlashBase)) {
282+ if (epicsRtemsMountLocalFilesystem(argv)==0) {
283+ return 1; /* FS setup successful */
284+ } else if (_FlashSize && (_DownloadLocation || _FlashBase)) {
285 extern char _edata[];
286 size_t flashIndex = _edata - _DownloadLocation;
287 char *header = _FlashBase + flashIndex;
288@@ -591,6 +619,7 @@
289 }
290 printf("\n***** Initializing network *****\n");
291 rtems_bsdnet_initialize_network();
292+ printf("\n***** Setting up file system *****\n");
293 initialize_remote_filesystem(argv, initialize_local_filesystem(argv));
294 fixup_hosts();
295
296
297=== modified file 'src/libCom/misc/testMain.h'
298--- src/libCom/misc/testMain.h 2010-10-05 19:27:37 +0000
299+++ src/libCom/misc/testMain.h 2016-03-01 02:02:15 +0000
300@@ -28,7 +28,13 @@
301 * }
302 */
303
304-#if defined(vxWorks) || defined(__rtems__)
305+#if defined(__rtems__)
306+ #ifdef __cplusplus
307+ #define MAIN(prog) extern "C" int prog(void); extern "C" int main() __attribute__((weak, alias(#prog))); extern "C" int prog(void)
308+ #else
309+ #define MAIN(prog) int prog(); int main() __attribute__((weak, alias(#prog))); int prog()
310+ #endif
311+#elif defined(vxWorks)
312 #ifdef __cplusplus
313 #define MAIN(prog) extern "C" int prog(void)
314 #else
315
316=== modified file 'src/libCom/test/Makefile'
317--- src/libCom/test/Makefile 2016-02-25 20:13:40 +0000
318+++ src/libCom/test/Makefile 2016-03-01 02:02:15 +0000
319@@ -12,11 +12,18 @@
320
321 PROD_LIBS += Com
322
323+PROD_SRCS_RTEMS += rtemsTestData.c
324+
325+ifeq ($(EPICS_HOST_ARCH),$(T_A))
326+# skip except for host arch due to custom .plt
327+
328 TESTPROD_HOST += epicsUnitTestTest
329 epicsUnitTestTest_SRCS += epicsUnitTestTest.c
330 # Not much point running this on vxWorks or RTEMS...
331 TESTS += epicsUnitTestTest
332
333+endif
334+
335 TESTPROD_HOST += epicsTypesTest
336 epicsTypesTest_SRCS += epicsTypesTest.cpp
337 testHarness_SRCS += epicsTypesTest.cpp
338@@ -222,6 +229,10 @@
339 TESTSPEC_RTEMS = libComTestHarness.boot; epicsRunLibComTests
340
341 TESTSCRIPTS_HOST += $(TESTS:%=%.t)
342+ifeq ($(T_A),RTEMS-pc386)
343+TESTPROD_RTEMS = $(TESTPROD_HOST)
344+TESTSCRIPTS_RTEMS += $(filter-out epicsUnitTestTest.t, $(TESTS:%=%.t))
345+endif
346
347
348 # The following are not test programs, they measure performance.
349
350=== added file 'src/libCom/test/rtemsTestData.c'
351--- src/libCom/test/rtemsTestData.c 1970-01-01 00:00:00 +0000
352+++ src/libCom/test/rtemsTestData.c 2016-03-01 02:02:15 +0000
353@@ -0,0 +1,6 @@
354+#include "epicsMemFs.h"
355+
356+/* no local files needed for these tests,
357+ * so skip local FS setup
358+ */
359+const epicsMemFS *epicsRtemsFSImage = NULL;
360
361=== modified file 'src/std/filters/test/Makefile'
362--- src/std/filters/test/Makefile 2012-07-23 03:40:43 +0000
363+++ src/std/filters/test/Makefile 2016-03-01 02:02:15 +0000
364@@ -64,6 +64,8 @@
365 filterTestHarness_SRCS += $(testHarness_SRCS)
366 filterTestHarness_SRCS_RTEMS += rtemsTestHarness.c
367
368+PROD_SRCS_RTEMS += rtemsTestData.c
369+
370 PROD_vxWorks = filterTestHarness
371 PROD_RTEMS = filterTestHarness
372
373@@ -71,6 +73,10 @@
374 TESTSPEC_RTEMS = filterTestHarness.boot; epicsRunFilterTests
375
376 TESTSCRIPTS_HOST += $(TESTS:%=%.t)
377+ifeq ($(T_A),RTEMS-pc386)
378+TESTPROD_RTEMS = $(TESTPROD_HOST)
379+TESTSCRIPTS_RTEMS += $(TESTS:%=%.t)
380+endif
381
382 include $(TOP)/configure/RULES
383
384@@ -80,3 +86,6 @@
385 syncTest$(DEP): $(COMMON_DIR)/xRecord.h
386 arrRecord$(DEP): $(COMMON_DIR)/arrRecord.h
387 arrTest$(DEP): $(COMMON_DIR)/arrRecord.h
388+
389+rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl
390+ $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES)
391
392=== modified file 'src/std/rec/test/Makefile'
393--- src/std/rec/test/Makefile 2016-03-01 01:37:25 +0000
394+++ src/std/rec/test/Makefile 2016-03-01 02:02:15 +0000
395@@ -71,6 +71,8 @@
396 recordTestHarness_SRCS += $(testHarness_SRCS)
397 recordTestHarness_SRCS_RTEMS += rtemsTestHarness.c
398
399+PROD_SRCS_RTEMS += rtemsTestData.c
400+
401 PROD_vxWorks = recordTestHarness
402 PROD_RTEMS = recordTestHarness
403
404@@ -78,5 +80,12 @@
405 TESTSPEC_RTEMS = recordTestHarness.boot; epicsRunRecordTests
406
407 TESTSCRIPTS_HOST += $(TESTS:%=%.t)
408+ifeq ($(T_A),RTEMS-pc386)
409+TESTPROD_RTEMS = $(TESTPROD_HOST)
410+TESTSCRIPTS_RTEMS += $(TESTS:%=%.t)
411+endif
412
413 include $(TOP)/configure/RULES
414+
415+rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl
416+ $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES)
417
418=== modified file 'src/tools/Makefile'
419--- src/tools/Makefile 2016-02-27 00:16:26 +0000
420+++ src/tools/Makefile 2016-03-01 02:02:15 +0000
421@@ -46,6 +46,7 @@
422 PERL_SCRIPTS += mkmf.pl
423 PERL_SCRIPTS += munch.pl
424 PERL_SCRIPTS += replaceVAR.pl
425+PERL_SCRIPTS += epicsMakeMemFs.pl
426 PERL_SCRIPTS += useManifestTool.pl
427 PERL_SCRIPTS += genVersionHeader.pl
428
429
430=== added file 'src/tools/epicsMakeMemFs.pl'
431--- src/tools/epicsMakeMemFs.pl 1970-01-01 00:00:00 +0000
432+++ src/tools/epicsMakeMemFs.pl 2016-03-01 02:02:15 +0000
433@@ -0,0 +1,83 @@
434+#!/usr/bin/env perl
435+#
436+
437+use File::Basename;
438+
439+use strict;
440+
441+my $outfile = shift;
442+my $varname = shift;
443+
444+open(my $DST, '>', $outfile) or die "Failed to open $outfile";
445+
446+print $DST <<EOF;
447+#include <epicsMemFs.h>
448+EOF
449+
450+my $N = 0;
451+
452+for my $fname (@ARGV) {
453+ print "<- $fname\n";
454+ my $realfname = $fname;
455+
456+ # strip leading "../" "./" or "/"
457+ while ($fname =~ /^\.*\/(.*)$/) { $fname = $1; }
458+
459+ my $file = basename($fname);
460+ my @dirs = split('/', dirname($fname));
461+
462+ print $DST "/* begin $realfname */\nstatic const char * const file_${N}_dir[] = {";
463+ for my $dpart (@dirs) {
464+ print $DST "\"$dpart\", ";
465+ }
466+ print $DST "NULL};\nstatic const char file_${N}_data[] = {\n ";
467+
468+ open(my $SRC, '<', $realfname) or die "Failed to open $realfname";
469+ binmode($SRC);
470+
471+ my $buf;
472+ my $total = 0;
473+ while (my $num = read($SRC, $buf, 32)) {
474+ if($total != 0) {
475+ print $DST ",\n ";
476+ }
477+ $total += $num;
478+ my $out = join(",",map(ord,split(//,$buf)));
479+ print $DST "$out";
480+ }
481+
482+ close($SRC);
483+
484+ print $DST <<EOF;
485+
486+};
487+static const epicsMemFile file_${N} = {
488+ file_${N}_dir,
489+ \"$file\",
490+ file_${N}_data,
491+ $total
492+};
493+/* end $realfname */
494+EOF
495+ $N = $N + 1;
496+}
497+
498+print $DST <<EOF;
499+static const epicsMemFile* files[] = {
500+EOF
501+
502+$N = $N - 1;
503+
504+for my $i (0..${N}) {
505+ print $DST " &file_${i},";
506+}
507+
508+print $DST <<EOF;
509+ NULL
510+};
511+static
512+const epicsMemFS ${varname}_image = {&files[0]};
513+const epicsMemFS * $varname = &${varname}_image;
514+EOF
515+
516+close($DST);
517
518=== modified file 'src/tools/makeTestfile.pl'
519--- src/tools/makeTestfile.pl 2015-03-11 21:26:15 +0000
520+++ src/tools/makeTestfile.pl 2016-03-01 02:02:15 +0000
521@@ -15,17 +15,43 @@
522 # If the script is given an argument -tap it sets HARNESS_ACTIVE in the
523 # environment to make the epicsUnitTest code generate strict TAP output.
524
525-# Usage: makeTestfile.pl target.t executable
526+# Usage: makeTestfile.pl <target-arch> <host-arch> target.t executable
527+# target-arch and host-arch are EPICS build target names (eg. linux-x86)
528 # target.t is the name of the Perl script to generate
529 # executable is the name of the file the script runs
530
531 use strict;
532
533-my ($target, $exe) = @ARGV;
534+my ($TA, $HA, $target, $exe) = @ARGV;
535+my $exec;
536+
537+# Use WINE to run windows target executables on non-windows host
538+if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) {
539+ $exec = "wine32 $exe";
540+} elsif( $TA =~ /^windows-x64/ && $HA !~ /^win/ ) {
541+ $exec = "wine64 $exe";
542+
543+# Run pc386 test harness w/ QEMU
544+} elsif( $TA =~ /^RTEMS-pc386$/ ) {
545+ $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -kernel $exe";
546+
547+# Explicitly fail for other RTEMS targets
548+} elsif( $TA =~ /^RTEMS-/ ) {
549+ die "I don't know how to run tests for $TA on $HA";
550+
551+} else {
552+ $exec = "./$exe";
553+}
554
555 # Use system on Windows, exec doesn't work the same there and
556 # GNUmake thinks the test has finished as soon as Perl exits.
557-my $exec = $^O eq 'MSWin32' ? "system('./$exe') == 0" : "exec './$exe'";
558+if( $HA =~ /^win/ ) {
559+ $exec = "system('$exec') == 0";
560+
561+# default to exec()
562+} else {
563+ $exec = "exec '$exec'";
564+}
565
566 open(my $OUT, '>', $target) or die "Can't create $target: $!\n";
567

Subscribers

People subscribed via source and target branches