Index: .fossil-settings/clean-glob ================================================================== --- .fossil-settings/clean-glob +++ .fossil-settings/clean-glob @@ -27,10 +27,11 @@ generators/library/gen_libraries generators/unicode/gen_tables new_tests/EBOOT.PBP new_tests/PARAM.SFO new_tests/plugin/Info.plist +new_tests/subprocess/subprocess new_tests/testfile_bin.m new_tests/tests new_tests/tests.3dsx new_tests/tests.arm9 new_tests/tests.nds @@ -48,11 +49,10 @@ tests/DerivedData tests/EBOOT.PBP tests/Info.plist tests/PARAM.SFO tests/objc_sync/objc_sync -tests/subprocess/subprocess tests/terminal/terminal_tests tests/testfile_bin.m tests/testfile_ini.m tests/tests tests/tests.3dsx Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -29,10 +29,11 @@ generators/library/gen_libraries generators/unicode/gen_tables new_tests/EBOOT.PBP new_tests/PARAM.SFO new_tests/plugin/Info.plist +new_tests/subprocess/subprocess new_tests/testfile_bin.m new_tests/tests new_tests/tests.3dsx new_tests/tests.arm9 new_tests/tests.nds @@ -53,11 +54,10 @@ tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata tests/objc_sync/objc_sync -tests/subprocess/subprocess tests/terminal/terminal_tests tests/testfile_bin.m tests/testfile_bin.m tests/testfile_ini.m tests/tests Index: .gitignore ================================================================== --- .gitignore +++ .gitignore @@ -29,10 +29,11 @@ generators/library/gen_libraries generators/unicode/gen_tables new_tests/EBOOT.PBP new_tests/PARAM.SFO new_tests/plugin/Info.plist +new_tests/subprocess/subprocess new_tests/testfile_bin.m new_tests/tests new_tests/tests.3dsx new_tests/tests.arm9 new_tests/tests.nds @@ -53,11 +54,10 @@ tests/PARAM.SFO tests/iOS.xcodeproj/*.pbxuser tests/iOS.xcodeproj/project.xcworkspace tests/iOS.xcodeproj/xcuserdata tests/objc_sync/objc_sync -tests/subprocess/subprocess tests/terminal/terminal_tests tests/testfile_bin.m tests/testfile_ini.m tests/tests tests/tests.3dsx Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1979,11 +1979,11 @@ break ]) ]) ]) AS_IF([test x"$have_subprocesses" = x"yes"], [ - AC_SUBST(USE_SRCS_SUBPROCESS, '${SRCS_SUBPROCESS}') + AC_SUBST(USE_SRCS_SUBPROCESSES, '${SRCS_SUBPROCESSES}') AC_SUBST(SUBPROCESS, "subprocess") AC_DEFINE(OF_HAVE_SUBPROCESSES, 1, [Whether we have subprocesses]) ]) AC_CHECK_HEADERS_ONCE([complex.h sys/ioctl.h sys/ttycom.h]) Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -84,11 +84,11 @@ USE_SRCS_APPLETALK = @USE_SRCS_APPLETALK@ USE_SRCS_FILES = @USE_SRCS_FILES@ USE_SRCS_IPX = @USE_SRCS_IPX@ USE_SRCS_PLUGINS = @USE_SRCS_PLUGINS@ USE_SRCS_SOCKETS = @USE_SRCS_SOCKETS@ -USE_SRCS_SUBPROCESS = @USE_SRCS_SUBPROCESS@ +USE_SRCS_SUBPROCESSES = @USE_SRCS_SUBPROCESSES@ USE_SRCS_TAGGED_POINTERS = @USE_SRCS_TAGGED_POINTERS@ USE_SRCS_THREADS = @USE_SRCS_THREADS@ USE_SRCS_UNIX_SOCKETS = @USE_SRCS_UNIX_SOCKETS@ USE_SRCS_WINDOWS = @USE_SRCS_WINDOWS@ WRAPPER = @WRAPPER@ Index: new_tests/Makefile ================================================================== --- new_tests/Makefile +++ new_tests/Makefile @@ -1,8 +1,8 @@ include ../extra.mk -SUBDIRS = ${TESTPLUGIN} +SUBDIRS = ${TESTPLUGIN} ${SUBPROCESS} CLEAN = testfile_bin.m PROG_NOINST = tests${PROG_SUFFIX} SRCS = OFArrayTests.m \ @@ -22,13 +22,15 @@ OFPBKDF2Tests.m \ OFPropertyListTests.m \ OFScryptTests.m \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ + ${USE_SRCS_SUBPROCESSES} \ testfile_bin.m SRCS_PLUGINS = OFPluginTests.m SRCS_SOCKETS = OFSocketTests.m +SRCS_SUBPROCESSES = OFSubprocessTests.m include ../buildsys.mk testfile_bin.m: testfile.bin ${SHELL} ../utils/objfw-embed testfile.bin testfile.bin $@ @@ -148,11 +150,12 @@ CPPFLAGS += -I../src \ -I../src/exceptions \ -I../src/runtime \ -I../src/test \ -I.. \ - -DOBJFWTEST_LOCAL_INCLUDES + -DOBJFWTEST_LOCAL_INCLUDES \ + -DPROG_SUFFIX=\"${PROG_SUFFIX}\" # Repetition is required for Wii U, as otherwise it cannot find main. Just # moving -lobjfwtest later doesn't work either, as then the linker cannot find # ObjFW symbols. So the only solution is to list everything twice. LIBS := -L../src/test \ -lobjfwtest \ ADDED new_tests/OFSubprocessTests.m Index: new_tests/OFSubprocessTests.m ================================================================== --- new_tests/OFSubprocessTests.m +++ new_tests/OFSubprocessTests.m @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008-2024 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "ObjFW.h" +#import "ObjFWTest.h" + +@interface OFSubprocessTests: OTTestCase +@end + +@implementation OFSubprocessTests +- (void)testSubprocess +{ +#ifdef OF_HAVE_FILES + OFString *program = [@"subprocess" stringByAppendingPathComponent: + @"subprocess" @PROG_SUFFIX]; +#else + OFString *program = @"subprocess/subprocess" @PROG_SUFFIX; +#endif + OFArray *arguments = [OFArray arrayWithObjects: @"tést", @"123", nil]; + OFMutableDictionary *environment = + [[[OFApplication environment] mutableCopy] autorelease]; + OFSubprocess *subprocess; + + [environment setObject: @"yés" forKey: @"tëst"]; + + subprocess = [OFSubprocess subprocessWithProgram: program + programName: program + arguments: arguments + environment: environment]; + + [subprocess writeLine: @"Hellö world!"]; + OTAssertEqualObjects([subprocess readLine], @"HELLÖ WORLD!"); + + [subprocess closeForWriting]; + + OTAssertEqual([subprocess waitForTermination], 0); +} +@end ADDED new_tests/subprocess/Makefile Index: new_tests/subprocess/Makefile ================================================================== --- new_tests/subprocess/Makefile +++ new_tests/subprocess/Makefile @@ -0,0 +1,9 @@ +PROG_NOINST = subprocess${PROG_SUFFIX} +SRCS = Subprocess.m + +include ../../buildsys.mk +include ../../extra.mk + +CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../.. +LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} +LD = ${OBJC} ADDED new_tests/subprocess/Subprocess.m Index: new_tests/subprocess/Subprocess.m ================================================================== --- new_tests/subprocess/Subprocess.m +++ new_tests/subprocess/Subprocess.m @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2008-2024 Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "ObjFW.h" + +@interface Subprocess: OFObject +@end + +OF_APPLICATION_DELEGATE(Subprocess) + +@implementation Subprocess +- (void)applicationDidFinishLaunching: (OFNotification *)notification +{ + OFString *line; + + if (![[OFApplication arguments] isEqual: + [OFArray arrayWithObjects: @"tést", @"123", nil]]) + [OFApplication terminateWithStatus: 1]; + + if (![[[OFApplication environment] objectForKey: @"tëst"] + isEqual: @"yés"]) + [OFApplication terminateWithStatus: 2]; + + while ((line = [OFStdIn readLine]) != nil) + [OFStdOut writeLine: line.uppercaseString]; + + [OFApplication terminate]; +} +@end Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -109,11 +109,11 @@ OFZIPArchive.m \ OFZIPArchiveEntry.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_PLUGINS} \ ${USE_SRCS_SOCKETS} \ - ${USE_SRCS_SUBPROCESS} \ + ${USE_SRCS_SUBPROCESSES} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} SRCS_FILES = OFFile.m \ OFString+PathAdditions.m SRCS_PLUGINS = OFPlugin.m @@ -155,11 +155,11 @@ SRCS_IPX = OFIPXSocket.m \ OFSPXSocket.m \ OFSPXStreamSocket.m SRCS_UNIX_SOCKETS = OFUNIXDatagramSocket.m \ OFUNIXStreamSocket.m -SRCS_SUBPROCESS = OFSubprocess.m +SRCS_SUBPROCESSES = OFSubprocess.m SRCS_THREADS = OFCondition.m \ OFMutex.m \ OFPlainCondition.m \ OFPlainMutex.m \ OFPlainThread.m \ Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,9 +1,8 @@ include ../extra.mk SUBDIRS = ${OBJC_SYNC} \ - ${SUBPROCESS} \ terminal CLEAN = EBOOT.PBP \ boot.dol \ ${PROG_NOINST}.arm9 \ @@ -38,11 +37,10 @@ RuntimeTests.m \ ${RUNTIME_ARC_TESTS_M} \ TestsAppDelegate.m \ ${USE_SRCS_FILES} \ ${USE_SRCS_SOCKETS} \ - ${USE_SRCS_SUBPROCESS} \ ${USE_SRCS_THREADS} \ ${USE_SRCS_WINDOWS} \ testfile_bin.m \ testfile_ini.m SRCS_SOCKETS = OFDNSResolverTests.m \ @@ -59,11 +57,10 @@ SRCS_IPX = OFIPXSocketTests.m \ OFSPXSocketTests.m \ OFSPXStreamSocketTests.m SRCS_UNIX_SOCKETS = OFUNIXDatagramSocketTests.m \ OFUNIXStreamSocketTests.m -SRCS_SUBPROCESS = OFSubprocessTests.m SRCS_THREADS = OFThreadTests.m SRCS_WINDOWS = OFWindowsRegistryKeyTests.m IOS_USER ?= mobile IOS_TMP ?= /tmp/objfw-test @@ -185,11 +182,10 @@ CPPFLAGS += -I../src \ -I../src/exceptions \ -I../src/runtime \ -I.. \ - -DSTDOUT \ - -DPROG_SUFFIX=\"${PROG_SUFFIX}\" + -DSTDOUT OBJCFLAGS_RuntimeARCTests.m = -fobjc-arc -fobjc-arc-exceptions LIBS := ${TESTS_LIBS} ${LIBS} LDFLAGS += ${MAP_LDFLAGS} LD = ${OBJC} DELETED tests/OFSubprocessTests.m Index: tests/OFSubprocessTests.m ================================================================== --- tests/OFSubprocessTests.m +++ tests/OFSubprocessTests.m @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2008-2024 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "TestsAppDelegate.h" - -static OFString *const module = @"OFSubprocess"; - -@implementation TestsAppDelegate (OFSubprocessTests) -- (void)subprocessTests -{ - void *pool = objc_autoreleasePoolPush(); -#ifdef OF_HAVE_FILES - OFString *program = [@"subprocess" stringByAppendingPathComponent: - @"subprocess" @PROG_SUFFIX]; -#else - OFString *program = @"subprocess/subprocess" @PROG_SUFFIX; -#endif - OFArray *arguments = [OFArray arrayWithObjects: @"tést", @"123", nil]; - OFMutableDictionary *environment = - [[[OFApplication environment] mutableCopy] autorelease]; - OFSubprocess *subprocess; - - [environment setObject: @"yés" forKey: @"tëst"]; - - TEST(@"+[subprocessWithProgram:programName:arguments:environment]", - (subprocess = - [OFSubprocess subprocessWithProgram: program - programName: program - arguments: arguments - environment: environment])) - - TEST(@"Standard input", R([subprocess writeLine: @"Hellö world!"])) - - TEST(@"Standard output", - [[subprocess readLine] isEqual: @"HELLÖ WORLD!"]) - - TEST(@"-[closeForWriting]", R([subprocess closeForWriting])) - - TEST(@"-[waitForTermination]", [subprocess waitForTermination] == 0) - - objc_autoreleasePoolPop(pool); -} -@end Index: tests/TestsAppDelegate.h ================================================================== --- tests/TestsAppDelegate.h +++ tests/TestsAppDelegate.h @@ -161,14 +161,10 @@ @interface TestsAppDelegate (OFStringTests) - (void)stringTests; @end -@interface TestsAppDelegate (OFSubprocessTests) -- (void)subprocessTests; -@end - @interface TestsAppDelegate (OFTCPSocketTests) - (void)TCPSocketTests; @end @interface TestsAppDelegate (OFThreadTests) Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -421,13 +421,10 @@ #endif [self XMLParserTests]; [self XMLNodeTests]; [self XMLElementBuilderTests]; -#ifdef OF_HAVE_SUBPROCESSES - [self subprocessTests]; -#endif #ifdef OF_WINDOWS [self windowsRegistryKeyTests]; #endif #ifdef OF_HAVE_SOCKETS DELETED tests/subprocess/Makefile Index: tests/subprocess/Makefile ================================================================== --- tests/subprocess/Makefile +++ tests/subprocess/Makefile @@ -1,9 +0,0 @@ -PROG_NOINST = subprocess${PROG_SUFFIX} -SRCS = Subprocess.m - -include ../../buildsys.mk -include ../../extra.mk - -CPPFLAGS += -I../../src -I../../src/exceptions -I../../src/runtime -I../.. -LIBS := -L../../src -lobjfw -L../../src/runtime ${RUNTIME_LIBS} ${LIBS} -LD = ${OBJC} DELETED tests/subprocess/Subprocess.m Index: tests/subprocess/Subprocess.m ================================================================== --- tests/subprocess/Subprocess.m +++ tests/subprocess/Subprocess.m @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2008-2024 Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "ObjFW.h" - -@interface Subprocess: OFObject -@end - -OF_APPLICATION_DELEGATE(Subprocess) - -@implementation Subprocess -- (void)applicationDidFinishLaunching: (OFNotification *)notification -{ - OFString *line; - - if (![[OFApplication arguments] isEqual: - [OFArray arrayWithObjects: @"tést", @"123", nil]]) - [OFApplication terminateWithStatus: 1]; - - if (![[[OFApplication environment] objectForKey: @"tëst"] - isEqual: @"yés"]) - [OFApplication terminateWithStatus: 2]; - - while ((line = [OFStdIn readLine]) != nil) - [OFStdOut writeLine: line.uppercaseString]; - - [OFApplication terminate]; -} -@end