ObjFW  Check-in [292b83bb90]

Overview
Comment:Fix tests/objc_sync
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 292b83bb90b23530b89835fd4dcdd4b7425f0f11fe7f1eced7edc7db6ca64e94
User & Date: js on 2017-07-02 19:30:09
Other Links: manifest | tags
Context
2017-07-08
15:00
Make blocks work on Windows with static lib check-in: cc519b99bf user: js tags: trunk
2017-07-02
19:30
Fix tests/objc_sync check-in: 292b83bb90 user: js tags: trunk
19:22
Use WRAPPER instead of TEST_LAUNCHER check-in: 08291826b1 user: js tags: trunk
Changes

Modified src/OFThread.h from [e4d351df51] to [f3aa3dc787].

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
167
168
169
170
171
172
173



174
175
176
177
178
179
180







-
-
-







 */
- initWithThreadBlock: (of_thread_block_t)threadBlock;
# endif

/*!
 * @brief The main routine of the thread. You need to reimplement this!
 *
 * It can access the object passed to the @ref threadWithObject: or
 * @ref initWithObject: method using the instance variable named object.
 *
 * @return The object the join method should return when called for this thread
 */
- (nullable id)main;

/*!
 * @brief This routine is executed when the thread's main method has finished
 *	  executing or terminate has been called.

Modified tests/objc_sync/Makefile from [21ce4d6811] to [9a7ef098a8].

1
2
3
4
5




6
7


8
9
10




11
12
13
14

15
16
17

18
19
20
21
22
23

















24
25
26
27
28

29
30
31





32
33
34
35
36
37
38
1
2
3
4
5
6
7
8
9


10
11
12
13

14
15
16
17
18
19
20

21
22
23

24
25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52


53
54
55
56
57
58
59


60
61
62





+
+
+
+
-
-
+
+


-
+
+
+
+



-
+


-
+





-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+




-
+

-
-
+
+
+
+
+


-
-



include ../../extra.mk

PROG_NOINST = objc_sync${PROG_SUFFIX}
SRCS = test.m

include ../../buildsys.mk

post-all: ${RUN_TESTS}

.PHONY: run-tests
run-tests: all
.PHONY: run
run:
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR}
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}
	rm -f libobjfw.dll libobjfw.dylib
	rm -f libobjfw.dll libobjfw.${OBJFW_LIB_MAJOR}.dylib
	rm -f libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR}
	rm -f libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR_MINOR}
	rm -f libobjfw-rt.dll libobjfw-rt.${OBJFW_RT_LIB_MAJOR}.dylib
	if test -f ../../src/libobjfw.so; then \
		${LN_S} ../../src/libobjfw.so libobjfw.so.${OBJFW_LIB_MAJOR}; \
		${LN_S} ../../src/libobjfw.so \
			libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
		    libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
	elif test -f ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; then \
		${LN_S} ../../src/libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} \
			libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
		    libobjfw.so.${OBJFW_LIB_MAJOR_MINOR}; \
	fi
	if test -f ../../src/libobjfw.dll; then \
		${LN_S} ../../src/libobjfw.dll libobjfw.dll; \
	fi
	if test -f ../../src/libobjfw.dylib; then \
		${LN_S} ../../src/libobjfw.dylib libobjfw.dylib; \
		${LN_S} ../../src/libobjfw.dylib \
		    libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
	fi
	if test -f ../../src/runtime/libobjfw-rt.so; then \
		${LN_S} ../../src/runtime/libobjfw-rt.so \
		    libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR}; \
		${LN_S} ../../src/runtime/libobjfw-rt.so \
		    libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR_MINOR}; \
	elif test -f ../../src/runtime/libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR_MINOR}; then \
		${LN_S} ../../src/runtime/libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR_MINOR} libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR_MINOR}; \
	fi
	if test -f ../../src/runtime/libobjfw-rt.dll; then \
		${LN_S} ../../src/runtime/libobjfw-rt.dll libobjfw-rt.dll; \
	fi
	if test -f ../../src/runtime/libobjfw-rt.dylib; then \
		${LN_S} ../../src/runtime/libobjfw-rt.dylib \
		    libobjfw-rt.${OBJFW_RT_LIB_MAJOR}.dylib; \
	fi
	LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
	DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
	LIBRARY_PATH=.$${LIBRARY_PATH+:}$$LIBRARY_PATH \
	${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \
	${WRAPPER} ./${PROG_NOINST}; EXIT=$$?; \
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR}; \
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} libobjfw.dll \
	rm -f libobjfw.dylib; \
	rm -f libobjfw.so.${OBJFW_LIB_MAJOR_MINOR} libobjfw.dll; \
	rm -f libobjfw.${OBJFW_LIB_MAJOR}.dylib; \
	rm -f libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR}; \
	rm -f libobjfw-rt.so.${OBJFW_RT_LIB_MAJOR_MINOR} libobjfw-rt.dll; \
	rm -f libobjfw-rt.${OBJFW_RT_LIB_MAJOR}.dylib; \
	exit $$EXIT

include ../../buildsys.mk

CPPFLAGS += -I../../src/runtime -I../../src -I../..
LIBS := -L../../src -lobjfw ${LIBS}
LD = ${OBJC}

Modified tests/objc_sync/test.m from [2fe868045e] to [a058419e78].

20
21
22
23
24
25
26
27
28
29
30
31

32


33

34
35

36
37

38
39

40
41

42
43
44
45
46
47
48
49


50

51
52





53
54
55
56
57
58
59
60
61
20
21
22
23
24
25
26

27
28
29

30
31
32
33

34
35

36
37

38
39

40
41

42
43
44
45
46
47
48
49
50
51
52
53
54


55
56
57
58
59
60
61
62
63
64
65
66
67
68







-



-
+

+
+
-
+

-
+

-
+

-
+

-
+








+
+

+
-
-
+
+
+
+
+










#import "OFString.h"
#import "OFThread.h"

OFObject *lock;

@interface MyThread: OFThread
- main;
@end

@implementation MyThread
- main
- (id)main
{
	const char *name = [[[OFThread currentThread] name] UTF8String];

	printf("[%s] Entering #1\n", [object UTF8String]);
	printf("[%s] Entering #1\n", name);
	@synchronized (lock) {
		printf("[%s] Entering #2\n", [object UTF8String]);
		printf("[%s] Entering #2\n", name);
		@synchronized (lock) {
			printf("[%s] Hello!\n", [object UTF8String]);
			printf("[%s] Hello!\n", name);
		}
		printf("[%s] Left #2\n", [object UTF8String]);
		printf("[%s] Left #2\n", name);
	}
	printf("[%s] Left #1\n", [object UTF8String]);
	printf("[%s] Left #1\n", name);

	return nil;
}
@end

int
main()
{
	MyThread *t1, *t2;

	lock = [[OFObject alloc] init];

	MyThread *t1 = [MyThread threadWithObject: @"A"];
	MyThread *t2 = [MyThread threadWithObject: @"B"];
	t1 = [MyThread thread];
	[t1 setName: @"A"];

	t2 = [MyThread thread];
	[t2 setName: @"B"];

	[t1 start];
	[t2 start];

	[t1 join];
	[t2 join];

	return 0;
}