ObjFW  Check-in [0ad8f57b16]

Overview
Comment:Migration of OFPlugin tests to new testing framework.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0ad8f57b16833327391f09b0fc7d12243de5763be14ac0357f346d0c2ac1a8ac
User & Date: js on 2009-10-01 12:44:37
Other Links: manifest | tags
Context
2009-10-03
11:51
Add +[tlsKey] to OFTLSKey. check-in: fad0ff6539 user: js tags: trunk
2009-10-01
12:44
Migration of OFPlugin tests to new testing framework. check-in: 0ad8f57b16 user: js tags: trunk
12:44
Let the init function of the plugin autorelease it. check-in: 62eddf9d21 user: js tags: trunk
Changes

Modified configure.ac from [2fd83093d6] to [5516946ed9].

15
16
17
18
19
20
21
22


23
24
25
26
27
28
29
30

AC_DEFINE(OF_CONFIGURED, 1, [Define so that we know we got our config.h])

BUILDSYS_LIB
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
if test x"$PLUGIN_SUFFIX" != "x"; then
	AC_SUBST(OFPLUGIN_M, "OFPlugin.m")
	AC_SUBST(OFPLUGIN, "OFPlugin")


	AC_SUBST(OFPLUGIN_DEF, "-DOF_PLUGINS")
fi

AC_C_BIGENDIAN([
	AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])
	AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN")
	])








|
>
>
|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

AC_DEFINE(OF_CONFIGURED, 1, [Define so that we know we got our config.h])

BUILDSYS_LIB
AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins])
if test x"$PLUGIN_SUFFIX" != "x"; then
	AC_SUBST(OFPLUGIN_M, "OFPlugin.m")
	AC_SUBST(PLUGIN_M, "plugin.m")
	AC_SUBST(TESTPLUGIN, "plugin")
	AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support])
	AC_SUBST(OFPLUGINS_DEF, "-DOF_PLUGINS")
fi

AC_C_BIGENDIAN([
	AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])
	AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN")
	])

Modified extra.mk.in from [f8de6158a0] to [a343e23c19].

1
2
3
4
5


6
7
8
ASPRINTF_C = @ASPRINTF_C@
OBJC_SYNC = @OBJC_SYNC@
OBJC_SYNC_M = @OBJC_SYNC_M@
OFPLUGIN = @OFPLUGIN@
OFPLUGIN_M = @OFPLUGIN_M@


WS2_LIBS = @WS2_LIBS@
TESTS = @TESTS@
TEST_LAUNCHER = @TEST_LAUNCHER@



<

>
>



1
2
3

4
5
6
7
8
9
ASPRINTF_C = @ASPRINTF_C@
OBJC_SYNC = @OBJC_SYNC@
OBJC_SYNC_M = @OBJC_SYNC_M@

OFPLUGIN_M = @OFPLUGIN_M@
PLUGIN_M = @PLUGIN_M@
TESTPLUGIN = @TESTPLUGIN@
WS2_LIBS = @WS2_LIBS@
TESTS = @TESTS@
TEST_LAUNCHER = @TEST_LAUNCHER@

Modified objfw-config.in from [99ac0f96fa] to [0a106bf29c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
CFLAGS=""
CPPFLAGS="-I@includedir@ -DOF_CONFIGURED @ENDIANESS_DEF@ @ASPRINTF_DEF@"
CPPFLAGS="$CPPFLAGS @OFPLUGIN_DEF@"
CXXFLAGS=""
OBJCFLAGS="-fobjc-exceptions -fconstant-string-class=OFConstString"
OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@"
LDFLAGS="@RPATH_LDFLAGS@"
LIBS="-L${libdir} -lobjfw @LIBS@"
VERSION="0.1"







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
CFLAGS=""
CPPFLAGS="-I@includedir@ -DOF_CONFIGURED @ENDIANESS_DEF@ @ASPRINTF_DEF@"
CPPFLAGS="$CPPFLAGS @OFPLUGINS_DEF@"
CXXFLAGS=""
OBJCFLAGS="-fobjc-exceptions -fconstant-string-class=OFConstString"
OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@"
LDFLAGS="@RPATH_LDFLAGS@"
LIBS="-L${libdir} -lobjfw @LIBS@"
VERSION="0.1"

Modified tests/Makefile from [2ad5747ae0] to [a9e8b7dd64].

1
2
3
4
5
6
7
8
include ../extra.mk

SUBDIRS = ${OFPLUGIN}		\
	  OFThread		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk


<
|




1
2

3
4
5
6
7
include ../extra.mk


SUBDIRS = OFThread		\
	  OFXMLParser		\
	  ${OBJC_SYNC}

include ../buildsys.mk

Deleted tests/OFPlugin/Makefile version [4c9d7d82c6].

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
SUBDIRS = TestPlugin

PROG_NOINST = ofplugin${PROG_SUFFIX}
SRCS = OFPlugin.m

include ../../buildsys.mk
include ../../extra.mk

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

.PHONY: run

all: run
run: subdirs ${PROG_NOINST}
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib
	if test -f ../../src/libobjfw.so; then \
		ln -s ../../src/libobjfw.so libobjfw.so.0; \
		ln -s ../../src/libobjfw.so libobjfw.so.0.1; \
	fi
	if test -f ../../src/libobjfw.dll; then \
		ln ../../src/libobjfw.dll libobjfw.dll; \
	fi
	if test -f ../../src/libobjfw.dylib; then \
		ln -s ../../src/libobjfw.dylib libobjfw.dylib; \
	fi
	LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
	DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
	${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \
	exit $$EXIT
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































Deleted tests/OFPlugin/OFPlugin.m version [3eae049364].

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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include <stdio.h>

#import "OFPlugin.h"
#import "TestPlugin/TestPlugin.h"

int
main()
{
	TestPlugin *plugin;

	plugin = [OFPlugin pluginFromFile: @"TestPlugin/TestPlugin"];
	if ([plugin test: 1234] != 2468) {
		puts("\033[K\033[1;31mTest 1/1 failed!\033[m");
		return 1;
	}

	puts("\033[1;32mTests successful: 1/1\033[0m");
	return 0;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































Deleted tests/OFPlugin/TestPlugin/Makefile version [9ce3d33173].

1
2
3
4
5
6
7
8
9
PLUGIN_NOINST = TestPlugin${PLUGIN_SUFFIX}
SRCS = TestPlugin.m

include ../../../buildsys.mk
include ../../../extra.mk

CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../../.. -I../../../src
OBJCFLAGS += ${PLUGIN_CFLAGS}
LIBS := -L../../../src -lobjfw ${LIBS}
<
<
<
<
<
<
<
<
<


















Deleted tests/OFPlugin/TestPlugin/TestPlugin.h version [d8aeffa07b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFPlugin.h"

@interface TestPlugin: OFPlugin
- (int)test: (int)num;
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































Deleted tests/OFPlugin/TestPlugin/TestPlugin.m version [be892b1df1].

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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#import "TestPlugin.h"

@implementation TestPlugin
- (int)test: (int)num
{
	return num * 2;
}
@end

id
init_plugin()
{
	return [[TestPlugin alloc] init];
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






















































Modified tests_new/Makefile from [cac1badf65] to [7122393b5c].





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









PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dataarray.m	\
       dictionary.m	\
       hashes.m		\
       list.m		\
       main.m		\
       object.m		\

       string.m		\
       tcpsocket.m	\
       xmlelement.m

include ../buildsys.mk
include ../extra.mk

CPPFLAGS += -I../src -I.. -DSTDOUT
LIBS := -L../src -lobjfw ${LIBS}

.PHONY: run

all: run
run: ${PROG_NOINST}
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib
	if test -f ../src/libobjfw.so; then \
		ln -s ../src/libobjfw.so libobjfw.so.0; \
		ln -s ../src/libobjfw.so libobjfw.so.0.1; \
	fi
	if test -f ../src/libobjfw.dll; then \
		ln ../src/libobjfw.dll libobjfw.dll; \
	fi
	if test -f ../src/libobjfw.dylib; then \
		ln -s ../src/libobjfw.dylib libobjfw.dylib; \
	fi
	LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
	DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
	${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \
	exit $$EXIT





>
>
>
>








>




<
<
<
<
<
<

<
<
|
















>
>
>
>
>
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
include ../extra.mk

SUBDIRS = ${TESTPLUGIN}

PROG_NOINST = tests${PROG_SUFFIX}
SRCS = array.m		\
       dataarray.m	\
       dictionary.m	\
       hashes.m		\
       list.m		\
       main.m		\
       object.m		\
       ${PLUGIN_M}	\
       string.m		\
       tcpsocket.m	\
       xmlelement.m







.PHONY: run


run: all
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib
	if test -f ../src/libobjfw.so; then \
		ln -s ../src/libobjfw.so libobjfw.so.0; \
		ln -s ../src/libobjfw.so libobjfw.so.0.1; \
	fi
	if test -f ../src/libobjfw.dll; then \
		ln ../src/libobjfw.dll libobjfw.dll; \
	fi
	if test -f ../src/libobjfw.dylib; then \
		ln -s ../src/libobjfw.dylib libobjfw.dylib; \
	fi
	LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \
	DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \
	${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \
	rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \
	exit $$EXIT

include ../buildsys.mk

CPPFLAGS += -I../src -I.. -DSTDOUT
LIBS := -L../src -lobjfw ${LIBS}

Modified tests_new/main.m from [44c304cc3d] to [3ca199df22].

21
22
23
24
25
26
27



28
29
30
31
32
33
34

extern void array_tests();
extern void dataarray_tests();
extern void dictionary_tests();
extern void hashes_tests();
extern void list_tests();
extern void object_tests();



extern void string_tests();
extern void tcpsocket_tests();
extern void xmlelement_tests();

static int fails = 0;

static void







>
>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

extern void array_tests();
extern void dataarray_tests();
extern void dictionary_tests();
extern void hashes_tests();
extern void list_tests();
extern void object_tests();
#ifdef OF_PLUGINS
extern void plugin_tests();
#endif
extern void string_tests();
extern void tcpsocket_tests();
extern void xmlelement_tests();

static int fails = 0;

static void
97
98
99
100
101
102
103



104
105
106
	string_tests();
	dataarray_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();
	xmlelement_tests();




	return fails;
}







>
>
>



100
101
102
103
104
105
106
107
108
109
110
111
112
	string_tests();
	dataarray_tests();
	array_tests();
	dictionary_tests();
	list_tests();
	tcpsocket_tests();
	xmlelement_tests();
#ifdef OF_PLUGINS
	plugin_tests();
#endif

	return fails;
}

Added tests_new/plugin.m version [5dcc6a3b22].











































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#import "OFPlugin.h"
#import "OFAutoreleasePool.h"
#import "OFString.h"
#import "OFExceptions.h"

#import "main.h"

#import "plugin/TestPlugin.h"

static OFString *module = @"OFPlugin";

void
plugin_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	TestPlugin *plugin;

	TEST(@"+[pluginFromFile:]",
	    (plugin = [OFPlugin pluginFromFile: @"plugin/TestPlugin"]))

	TEST(@"TestPlugin's -[test:]", [plugin test: 1234] == 2468)

	[pool release];
}

Added tests_new/plugin/Makefile version [e989e12b45].



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
PLUGIN_NOINST = TestPlugin${PLUGIN_SUFFIX}
SRCS = TestPlugin.m

include ../../buildsys.mk
include ../../extra.mk

CPPFLAGS += ${PLUGIN_CPPFLAGS} -I../.. -I../../src
OBJCFLAGS += ${PLUGIN_CFLAGS}
LIBS := -L../../src -lobjfw ${LIBS}

Added tests_new/plugin/TestPlugin.h version [d8aeffa07b].

































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFPlugin.h"

@interface TestPlugin: OFPlugin
- (int)test: (int)num;
@end

Added tests_new/plugin/TestPlugin.m version [fb32100b38].























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#import "TestPlugin.h"

@implementation TestPlugin
- (int)test: (int)num
{
	return num * 2;
}
@end

id
init_plugin()
{
	return [[[TestPlugin alloc] init] autorelease];
}