Skip to content

Commit 3a02dcd

Browse files
authored
Merge pull request #68 from mdavidsaver/win32
Extend portability
2 parents a9ae57b + bc6546e commit 3a02dcd

12 files changed

+286
-74
lines changed

.github/workflows/ci-scripts-build.yml

+69-26
Original file line numberDiff line numberDiff line change
@@ -16,80 +16,122 @@ env:
1616

1717
jobs:
1818
build-client:
19-
name: ${{ matrix.base }}/${{ matrix.os }}/${{ matrix.cmp }}/${{ matrix.configuration }}${{ matrix.rtems }}/${{ matrix.extra }}
19+
name: ${{ matrix.name }}
2020
runs-on: ${{ matrix.os }}
2121
# Set environment variables from matrix parameters
2222
env:
2323
BASE: ${{ matrix.base }}
2424
CMP: ${{ matrix.cmp }}
2525
BCFG: ${{ matrix.configuration }}
26-
RTEMS: ${{ matrix.rtems }}
26+
CI_CROSS_TARGETS: ${{ matrix.cross }}
2727
EXTRA: ${{ matrix.extra }}
2828
TEST: ${{ matrix.test }}
2929
strategy:
3030
fail-fast: false
3131
matrix:
3232
include:
33-
- os: ubuntu-latest
33+
- name: Linux-Mingw-7.0
34+
os: ubuntu-latest
3435
cmp: gcc
3536
configuration: default
3637
base: "7.0"
37-
wine: "64"
38+
cross: "windows-x64-mingw"
3839

39-
- os: ubuntu-latest
40+
- name: Linux-static-7.0
41+
os: ubuntu-latest
4042
cmp: gcc
4143
configuration: static
4244
base: "7.0"
4345

44-
- os: ubuntu-latest
46+
- name: Linux-3.15
47+
os: ubuntu-latest
4548
cmp: gcc
4649
configuration: default
4750
base: "3.15"
4851

49-
- os: ubuntu-latest
52+
- name: Linux-3.14
53+
os: ubuntu-latest
5054
cmp: gcc
5155
configuration: default
5256
base: "3.14"
5357

54-
- os: ubuntu-latest
58+
- name: Linux-c++11-7.0
59+
os: ubuntu-latest
5560
cmp: gcc
5661
configuration: static
5762
base: "7.0"
5863
extra: "CMD_CXXFLAGS=-std=c++11"
5964

60-
- os: ubuntu-latest
61-
cmp: gcc
65+
- name: Linux-clang-7.0
66+
os: ubuntu-latest
67+
cmp: clang
6268
configuration: default
6369
base: "7.0"
6470

65-
- os: ubuntu-latest
71+
- name: Linux-clang-c++11-7.0
72+
os: ubuntu-latest
6673
cmp: clang
6774
configuration: default
6875
base: "7.0"
6976
extra: "CMD_CXXFLAGS=-std=c++11"
7077

71-
- os: ubuntu-latest
78+
- name: Linux-rtems5-7.0
79+
os: ubuntu-20.04
80+
cmp: gcc
81+
configuration: default
82+
base: "7.0"
83+
cross: "RTEMS-pc686-qemu@5"
84+
85+
- name: Linux-rtems4.10-7.0
86+
os: ubuntu-20.04
7287
cmp: gcc
7388
configuration: default
7489
base: "7.0"
75-
rtems: "4.10"
90+
91+
test: NO
7692

77-
- os: ubuntu-latest
93+
- name: Linux-rtems4.9-7.0
94+
os: ubuntu-20.04
7895
cmp: gcc
7996
configuration: default
8097
base: "7.0"
81-
rtems: "4.9"
98+
cross: "RTEMS-pc386-qemu@4.9"
8299

83-
- os: ubuntu-latest
100+
- name: OSX-7.0
101+
os: macos-latest
84102
cmp: clang
85103
configuration: default
86104
base: "7.0"
87105

106+
- name: msvc-7.0
107+
os: windows-latest
108+
cmp: vs2022
109+
configuration: default
110+
base: "7.0"
111+
112+
- name: msvc-static-7.0
113+
os: windows-latest
114+
cmp: vs2022
115+
configuration: static
116+
base: "7.0"
117+
118+
- name: msvc-debug-7.0
119+
os: windows-latest
120+
cmp: vs2022
121+
configuration: debug
122+
base: "7.0"
123+
124+
- name: mingw-7.0
125+
os: windows-latest
126+
cmp: gcc
127+
configuration: default
128+
base: "7.0"
129+
88130
defaults:
89131
run:
90132
working-directory: client
91133
steps:
92-
- uses: actions/checkout@v2
134+
- uses: actions/checkout@v3
93135
with:
94136
submodules: true
95137
- name: Automatic core dump analysis
@@ -105,14 +147,15 @@ jobs:
105147
run: python .ci/cue.py build
106148
- name: Run main module tests
107149
run: python .ci/cue.py test
108-
- name: Collect and show test results
109-
run: python .ci/cue.py test-results
110150
- name: Upload tapfiles Artifact
111151
if: ${{ always() }}
112-
uses: actions/upload-artifact@v2
152+
uses: actions/upload-artifact@v3
113153
with:
114154
name: tapfiles ${{ matrix.name }}
115155
path: '**/O.*/*.tap'
156+
- name: Collect and show test results
157+
if: ${{ always() }}
158+
run: python .ci/cue.py test-results
116159

117160
docker:
118161
name: ${{ matrix.name }}
@@ -123,7 +166,6 @@ jobs:
123166
CMP: ${{ matrix.cmp }}
124167
BCFG: ${{ matrix.configuration }}
125168
BASE: ${{ matrix.base }}
126-
WINE: ${{ matrix.wine }}
127169
LIBEVENT_TAG: ${{ matrix.libevent }}
128170
EXTRA: ${{ matrix.extra }}
129171
VV: "1"
@@ -169,7 +211,7 @@ jobs:
169211
# people would rather just break all existing scripts...
170212
[ -e /usr/bin/python ] || ln -sf /usr/bin/python3 /usr/bin/python
171213
python --version
172-
- uses: actions/checkout@v2
214+
- uses: actions/checkout@v3
173215
with:
174216
submodules: true
175217
- name: Automatic core dumper analysis
@@ -183,12 +225,13 @@ jobs:
183225
- name: Run main module tests
184226
working-directory: ./client
185227
run: python .ci/cue.py test
186-
- name: Collect and show test results
187-
working-directory: ./client
188-
run: python .ci/cue.py test-results
189228
- name: Upload tapfiles Artifact
190229
if: ${{ always() }}
191-
uses: actions/upload-artifact@v2
230+
uses: actions/upload-artifact@v3
192231
with:
193232
name: tapfiles ${{ matrix.name }}
194233
path: '**/O.*/*.tap'
234+
- name: Collect and show test results
235+
if: ${{ always() }}
236+
working-directory: ./client
237+
run: python .ci/cue.py test-results

client/castApp/src/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ LIBRARY_IOC = reccaster
1010
# Will increment with ABI changes
1111
SHRLIB_VERSION = 0
1212

13+
PROD_SYS_LIBS_WIN32 = iphlpapi netapi32 ws2_32
14+
LIB_SYS_LIBS_WIN32 = iphlpapi netapi32 ws2_32
15+
1316
reccaster_SRCS += sockhelpers.c
1417
reccaster_SRCS += caster.c
1518
reccaster_SRCS += castudp.c
@@ -46,6 +49,10 @@ testAddEnvVars_SYS_LIBS_WIN32 = ws2_32
4649
TESTS += testAddEnvVars
4750

4851
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
52+
ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),)
53+
TESTPROD = $(TESTPROD_HOST)
54+
TESTSCRIPTS += $(TESTSCRIPTS_HOST)
55+
endif
4956

5057
#===========================
5158

client/castApp/src/caster.c

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <string.h>
55

66
#include <errlog.h>
7-
#include <cantProceed.h>
87
#include <epicsAssert.h>
98
#include <epicsThread.h>
109
#include <epicsStdio.h>
@@ -102,8 +101,7 @@ static void casterThread(void* junk)
102101
static
103102
void casterShowMsgDefault(void* arg, struct _caster_t* self)
104103
{
105-
errlogMessage(self->lastmsg);
106-
errlogMessage("\n");
104+
errlogPrintf("%s\n", self->lastmsg);
107105
}
108106

109107
void casterInit(caster_t *self)
@@ -118,7 +116,7 @@ void casterInit(caster_t *self)
118116
self->timeout = reccastTimeout;
119117

120118
if(shSocketPair(self->wakeup))
121-
cantProceed("casterInit failed to create shutdown socket");
119+
errlogPrintf("Error: casterInit failed to create shutdown socket: %d\n", SOCKERRNO);
122120
}
123121

124122
void casterShutdown(caster_t *self)
@@ -130,8 +128,10 @@ void casterShutdown(caster_t *self)
130128
self->shutdown = 1;
131129
epicsMutexUnlock(self->lock);
132130

133-
if(sizeof(junk)!=send(self->wakeup[0], (char*)&junk, sizeof(junk), 0))
134-
cantProceed("casterShutdown notification failed");
131+
if(sizeof(junk)!=send(self->wakeup[0], (char*)&junk, sizeof(junk), 0)) {
132+
errlogPrintf("Warning: casterShutdown notification failed. Skipping.");
133+
return;
134+
}
135135

136136
epicsEventMustWait(self->shutdownEvent);
137137

@@ -153,6 +153,10 @@ void casterShutdown(caster_t *self)
153153
int casterStart(caster_t *self)
154154
{
155155
epicsThreadId id;
156+
if(self->wakeup[0]==INVALID_SOCKET) {
157+
/* casterInit() failed */
158+
return 2;
159+
}
156160
id = epicsThreadCreate("reccaster",
157161
epicsThreadPriorityMedium,
158162
epicsThreadGetStackSize(epicsThreadStackSmall),

client/castApp/src/castinit.c

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ static void addReccasterEnvVarsCallFunc(const iocshArgBuf *args)
202202

203203
static void reccasterRegistrar(void)
204204
{
205+
osiSockAttach();
205206
initHookRegister(&casthook);
206207
casterInit(&thecaster);
207208
thepriv.lock = epicsMutexMustCreate();

client/castApp/src/casttcp.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int doCasterTCPPhase(caster_t *self)
2929
ERRRET(-1, self, "Failed to create socket");
3030

3131
if(shConnect(&sock, &self->nameserv))
32-
ERRTO(done, self, "caster failed to connect");
32+
ERRTO(done, self, "Failed to connect (%d)", (int)SOCKERRNO);
3333

3434
if(self->testhook)
3535
(*self->testhook)(self, casterTCPSetup);
@@ -74,10 +74,14 @@ int doCasterTCPPhase(caster_t *self)
7474
shSetTimeout(&sock, self->timeout*4.0);
7575

7676
while(!self->shutdown) {
77+
int err;
7778
blen = casterRecvPMsg(&sock, &msgid, &buf.bytes, sizeof(buf.bytes), 0);
79+
err = SOCKERRNO;
7880
if(blen==0)
7981
break; /* normal end of connection */
80-
else if(blen<0 && SOCKERRNO==SOCK_ETIMEDOUT)
82+
else if(blen<0 && (err==SOCK_ECONNRESET || err==SOCK_ECONNABORTED))
83+
ERRTO(done, self, "RecCaster connection closed by peer");
84+
else if(blen<0 && err==SOCK_ETIMEDOUT)
8185
ERRTO(done, self, "RecCaster server timeout");
8286
else if(blen<0)
8387
ERRTO(done, self, "Missing ping header");

0 commit comments

Comments
 (0)