this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

runtest improvements, partial fcntl(), various missing files

+416 -42
+30
src/CoreSecurity/CMakeLists.txt
··· 1 + project(CoreSecurity) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + if(COMMAND cmake_policy) 5 + cmake_policy(SET CMP0003 NEW) 6 + endif(COMMAND cmake_policy) 7 + 8 + enable_language(ASM_NASM) 9 + 10 + #if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 11 + # message(FATAL_ERROR "Clang is the only supported compiler.") 12 + #endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 13 + 14 + #configure_file(config.h.in config.h) 15 + 16 + add_definitions(-D__STDC_LIMIT_MACROS) 17 + 18 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fPIC") 19 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fPIC") 20 + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIC") 21 + 22 + set(cs_SRCS 23 + keychain.c 24 + ) 25 + 26 + add_library(CoreSecurity SHARED ${cs_SRCS}) 27 + target_link_libraries(CoreSecurity) 28 + 29 + install(TARGETS CoreSecurity DESTINATION "lib${SUFFIX}") 30 +
+7
src/CoreSecurity/dummy.h
··· 1 + #ifndef CORESECURITY_DUMMY_H 2 + #define CORESECURITY_DUMMY_H 3 + 4 + #define DUMMY(name) int name () { return -4; } 5 + 6 + #endif 7 +
+2
src/CoreSecurity/keychain.c
··· 1 + #include "keychain.h" 2 +
+12
src/CoreSecurity/keychain.h
··· 1 + #ifndef CORESECURITY_KEYCHAIN_H 2 + #define CORESECURITY_KEYCHAIN_H 3 + #include "dummy.h" 4 + 5 + DUMMY(SecCertificateGetData); 6 + DUMMY(SecKeychainItemCopyContent); 7 + DUMMY(SecKeychainItemFreeContent); 8 + DUMMY(SecKeychainOpen); 9 + DUMMY(SecKeychainSearchCopyNext); 10 + DUMMY(SecKeychainSearchCreateFromAttributes); 11 + 12 + #endif
+2
src/crash/CMakeLists.txt
··· 9 9 # message(FATAL_ERROR "Clang is the only supported compiler.") 10 10 #endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 11 11 12 + # CMake is broken and uses C++ flags for ObjC 13 + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") 12 14 13 15 set(crash_SRCS 14 16 AppController.m
+3
src/crash/CrashManager.m
··· 2 2 #include <Foundation/NSProcessInfo.h> 3 3 #include <Foundation/NSArray.h> 4 4 #include <Foundation/NSString.h> 5 + #include <Foundation/NSFileManager.h> 5 6 #include "CrashManager.h" 6 7 7 8 @implementation CrashManager ··· 45 46 46 47 [elems release]; 47 48 [text release]; 49 + 50 + [[NSFileManager defaultManager] removeItemAtPath:dumpPath error:NULL]; 48 51 } 49 52 50 53 return self;
+1
src/libSystem/CMakeLists.txt
··· 77 77 kernel-bsd/wait.cpp 78 78 kernel-bsd/sockets.cpp 79 79 kernel-bsd/fs.cpp 80 + kernel-bsd/fcntl.cpp 80 81 ) 81 82 82 83 set(machkern_SRCS
+4
src/libSystem/kernel-bsd/fopsmisc.h
··· 2 2 #define FOPSMISC_H 3 3 #include <sys/stat.h> 4 4 5 + #ifdef __cplusplus 5 6 extern "C" 6 7 { 8 + #endif 7 9 8 10 int __darwin_access(const char *pathname, int mode); 9 11 int __darwin_chown(const char *path, uid_t owner, gid_t group); ··· 25 27 int __darwin_chdir(const char *path); 26 28 int __darwin_acct(const char *filename); 27 29 30 + #ifdef __cplusplus 28 31 } 32 + #endif 29 33 30 34 #endif 31 35
+4 -1
src/libSystem/kernel-bsd/fs.h
··· 63 63 long f_reserved4[4]; 64 64 }; 65 65 66 - 66 + #ifdef __cplusplus 67 67 extern "C" 68 68 { 69 + #endif 69 70 70 71 int __darwin_statfs(const char* path, struct __darwin_statfs* buf); 71 72 int __darwin_statfs64(const char* path, struct __darwin_statfs64* buf) asm("__darwin_statfs$INODE64"); ··· 74 75 int __darwin_getfsstat(struct __darwin_statfs* buf, int bufsize, int flags); 75 76 int __darwin_getfsstat64(struct __darwin_statfs64* buf, int bufsize, int flags) asm("__darwin_getfsstat$INODE64"); 76 77 78 + #ifdef __cplusplus 77 79 } 78 80 79 81 // out assumed to have been zeroed out ··· 82 84 83 85 struct mntent; 84 86 struct mntent* findMountForPath(const char* path); 87 + #endif 85 88 86 89 #endif
+22 -35
src/libSystem/kernel-bsd/io.cpp
··· 11 11 12 12 extern char g_sysroot[PATH_MAX]; 13 13 14 + static const Darling::MappedFlag g_openflags[] = { 15 + { DARWIN_O_ASYNC, O_ASYNC}, { DARWIN_O_SYNC, O_SYNC }, { DARWIN_O_NOFOLLOW, O_NOFOLLOW}, 16 + { DARWIN_O_CREAT, O_CREAT }, { DARWIN_O_TRUNC, O_TRUNC }, { DARWIN_O_EXCL, O_EXCL }, 17 + { DARWIN_O_NOCTTY, O_NOCTTY }, { DARWIN_O_DIRECTORY, O_DIRECTORY }, { DARWIN_O_DSYNC, O_DSYNC }, 18 + }; 19 + 20 + int Darling::openflagsDarwinToNative(int flags) 21 + { 22 + return Darling::flagsDarwinToNative(g_openflags, sizeof(g_openflags)/sizeof(g_openflags[0]), flags); 23 + } 24 + 25 + int Darling::openflagsNativeToDarwin(int flags) 26 + { 27 + return Darling::flagsNativeToDarwin(g_openflags, sizeof(g_openflags)/sizeof(g_openflags[0]), flags); 28 + } 29 + 14 30 int __darwin_open(const char* path, int flags, mode_t mode) 15 31 { 16 32 TRACE3(path,flags,mode); 17 33 18 34 int linux_flags = 0; 19 35 linux_flags |= flags & O_ACCMODE; 20 - 21 - if (flags & DARWIN_O_SHLOCK) 36 + 37 + if (flags & ( DARWIN_O_EVTONLY|DARWIN_O_SYMLINK|DARWIN_O_POPUP|DARWIN_O_ALERT)) 22 38 { 39 + LOG << "Unsupported open flags: " << flags << std::endl; 23 40 errno = DARWIN_EINVAL; 24 - fprintf(stderr, "Unsupported open flag=%d\n", flags); 25 41 return -1; 26 42 } 43 + linux_flags |= Darling::flagsDarwinToNative(g_openflags, sizeof(g_openflags)/sizeof(g_openflags[0]), flags); 27 44 28 - if (flags & DARWIN_O_EXLOCK) 29 - { 30 - fprintf(stderr, "Unsupported open flag=%d\n", flags); 31 - errno = DARWIN_EINVAL; 32 - return -1; 33 - } 34 - if (flags & DARWIN_O_ASYNC) linux_flags |= O_ASYNC; 35 - if (flags & DARWIN_O_SYNC) linux_flags |= O_SYNC; 36 - if (flags & DARWIN_O_NOFOLLOW) linux_flags |= O_NOFOLLOW; 37 - if (flags & DARWIN_O_CREAT) linux_flags |= O_CREAT; 38 - if (flags & DARWIN_O_TRUNC) linux_flags |= O_TRUNC; 39 - if (flags & DARWIN_O_EXCL) linux_flags |= O_EXCL; 40 - 41 - if (flags & DARWIN_O_EVTONLY) 45 + if (flags & DARWIN_O_SHLOCK) 42 46 { 43 47 errno = DARWIN_EINVAL; 44 48 fprintf(stderr, "Unsupported open flag=%d\n", flags); 45 49 return -1; 46 50 } 47 - if (flags & DARWIN_O_NOCTTY) linux_flags |= O_NOCTTY; 48 - if (flags & DARWIN_O_DIRECTORY) linux_flags |= O_DIRECTORY; 49 51 50 - if (flags & DARWIN_O_SYMLINK) 51 - { 52 - errno = DARWIN_EINVAL; 53 - fprintf(stderr, "Unsupported open flag=%d\n", flags); 54 - return -1; 55 - } 56 - if (flags & DARWIN_O_DSYNC) linux_flags |= O_DSYNC; 57 - 58 - if (flags & DARWIN_O_POPUP) 52 + if (flags & DARWIN_O_EXLOCK) 59 53 { 60 - errno = DARWIN_EINVAL; 61 54 fprintf(stderr, "Unsupported open flag=%d\n", flags); 62 - return -1; 63 - } 64 - 65 - if (flags & DARWIN_O_ALERT) 66 - { 67 55 errno = DARWIN_EINVAL; 68 - fprintf(stderr, "Unsupported open flag=%d\n", flags); 69 56 return -1; 70 57 } 71 58
+10
src/libSystem/kernel-bsd/io.h
··· 20 20 #define DARWIN_O_POPUP 0x80000000 21 21 #define DARWIN_O_ALERT 0x20000000 22 22 23 + #ifdef __cplusplus 23 24 extern "C" 24 25 { 26 + #endif 25 27 26 28 int __darwin_open(const char* path, int flags, mode_t mode); 27 29 int __darwin_creat(const char *pathname, mode_t mode); ··· 29 31 int __darwin_fsync(int fd); 30 32 int __darwin_fdatasync(int fd); 31 33 34 + #ifdef __cplusplus 32 35 } 36 + 37 + namespace Darling 38 + { 39 + int openflagsDarwinToNative(int flags); 40 + int openflagsNativeToDarwin(int flags); 41 + } 42 + #endif 33 43 34 44 #endif
+4
src/libSystem/kernel-bsd/sockets.h
··· 28 28 #define DARWIN_AF_IPX 23 29 29 #define DARWIN_AF_INET6 30 30 30 31 + #ifdef __cplusplus 31 32 extern "C" 32 33 { 34 + #endif 33 35 34 36 int __darwin_select(int fd, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout); 35 37 ssize_t __darwin_sendto(int socket, const void *buffer, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len); ··· 43 45 int __darwin_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 44 46 int __darwin_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); 45 47 48 + #ifdef __cplusplus 46 49 } 47 50 48 51 namespace Darling ··· 52 55 bool sockaddrFixupIn(struct sockaddr* addr, socklen_t len); 53 56 bool sockaddrFixupOut(struct sockaddr* addr, socklen_t len); 54 57 } 58 + #endif 55 59 56 60 #endif
+4
src/libSystem/kernel-bsd/stat.h
··· 66 66 __int64_t st_qspare[2]; 67 67 }; 68 68 69 + #ifdef __cplusplus 69 70 extern "C" 70 71 { 72 + #endif 71 73 72 74 int __darwin_stat64(const char* path, struct __darwin_stat64* mac) asm("__darwin_stat$INODE64"); 73 75 int __darwin_fstat64(int fd, struct __darwin_stat64* mac) asm("__darwin_fstat$INODE64"); ··· 77 79 int __darwin_fstat(int fd, struct __darwin_stat* mac); 78 80 int __darwin_lstat(const char* path, struct __darwin_stat* mac); 79 81 82 + #ifdef __cplusplus 80 83 } 84 + #endif 81 85 82 86 #endif
+4
src/libSystem/kernel-bsd/wait.h
··· 2 2 #define BSD_WAIT_H 3 3 #include <sys/wait.h> 4 4 5 + #ifdef __cplusplus 5 6 extern "C" 6 7 { 8 + #endif 7 9 8 10 int __darwin_kill(pid_t pid, int sig); 9 11 pid_t __darwin_wait(int *stat_loc); ··· 11 13 pid_t __darwin_wait4(pid_t pid, int *stat_loc, int options, struct rusage *rusage); 12 14 pid_t __darwin_waitpid(pid_t pid, int *stat_loc, int options); 13 15 16 + #ifdef __cplusplus 14 17 } 18 + #endif 15 19 16 20 #endif
+4
src/libSystem/kernel-mach/host.h
··· 10 10 long dummy; 11 11 }; 12 12 13 + #ifdef __cplusplus 13 14 extern "C" 14 15 { 16 + #endif 15 17 16 18 typedef host* host_t; 17 19 typedef long host_priv_t; ··· 22 24 kern_return_t host_statistics(host_t host, int flavor, void* out, long* out_cnt); 23 25 host_t mach_host_self(); 24 26 27 + #ifdef __cplusplus 25 28 } 29 + #endif 26 30 27 31 #endif
+4
src/libSystem/kernel-mach/lockset.h
··· 6 6 struct lock_set; 7 7 typedef lock_set* lock_set_t; 8 8 9 + #ifdef __cplusplus 9 10 extern "C" { 11 + #endif 10 12 11 13 kern_return_t lock_acquire(lock_set_t lock_set, int lock_id); 12 14 ··· 24 26 25 27 kern_return_t lock_try (lock_set_t lock_set, int lock_id); 26 28 29 + #ifdef __cplusplus 27 30 } 31 + #endif 28 32 29 33 30 34 #endif
+4
src/libSystem/kernel-mach/misc.h
··· 2 2 #define MACH_MISC_H 3 3 #include <mach/kern_return.h> 4 4 5 + #ifdef __cplusplus 5 6 extern "C" 6 7 { 8 + #endif 7 9 8 10 char* mach_error_string(kern_return_t rv); 9 11 12 + #ifdef __cplusplus 10 13 } 14 + #endif 11 15 12 16 #endif
+4
src/libSystem/kernel-mach/semaphore.h
··· 11 11 12 12 typedef semaphore* esemaphore_t; 13 13 14 + #ifdef __cplusplus 14 15 extern "C" 15 16 { 17 + #endif 16 18 17 19 kern_return_t semaphore_create(darwin_task_t task, esemaphore_t *semaphore, int policy, int value); 18 20 ··· 24 26 25 27 kern_return_t semaphore_wait(esemaphore_t semaphore); 26 28 29 + #ifdef __cplusplus 27 30 } 31 + #endif 28 32 29 33 #endif 30 34
+4
src/libSystem/kernel-mach/task.h
··· 11 11 12 12 typedef darwin_task* darwin_task_t; 13 13 14 + #ifdef __cplusplus 14 15 extern "C" 15 16 { 17 + #endif 16 18 extern darwin_task_t mach_task_self_; 17 19 inline darwin_task_t mach_task_self() { return mach_task_self_; } 18 20 kern_return_t mach_port_deallocate(darwin_task_t task, void* port); 21 + #ifdef __cplusplus 19 22 } 23 + #endif 20 24 21 25 #endif
+4
src/libSystem/kernel-mach/time.h
··· 3 3 #include <stdint.h> 4 4 #include <mach/mach_time.h> 5 5 6 + #ifdef __cplusplus 6 7 extern "C" 7 8 { 9 + #endif 8 10 9 11 uint64_t mach_absolute_time(); 10 12 int mach_timebase_info(struct mach_timebase_info* info); 11 13 14 + #ifdef __cplusplus 12 15 } 16 + #endif 13 17 14 18 #endif
+4 -1
src/libSystem/kernel-mach/vm.h
··· 12 12 #include <mach/vm_types.h> 13 13 #include <mach/memory_object_types.h> 14 14 15 + #ifdef __cplusplus 15 16 extern "C" 16 17 { 18 + #endif 17 19 18 20 typedef darwin_task_t vm_task_t; 19 21 ··· 42 44 43 45 kern_return_t vm_wire(host_priv_t host, vm_task_t target_task, void* address, vm_size_t size, vm_prot_t wired_access); 44 46 45 - 47 + #ifdef __cplusplus 46 48 } // extern "C" 49 + #endif 47 50 48 51 #endif
+4
src/libSystem/libc/OSAtomic.h
··· 10 10 long l; 11 11 }; 12 12 13 + #ifdef __cplusplus 13 14 extern "C" { 15 + #endif 14 16 15 17 int32_t OSAtomicAdd32(int32_t theAmount, volatile int32_t *theValue); 16 18 ··· 98 100 99 101 void* OSAtomicDequeue(OSQueueHead *list, size_t offset); 100 102 103 + #ifdef __cplusplus 101 104 } 105 + #endif 102 106 103 107 #endif 104 108
+4
src/libSystem/libc/aio.h
··· 2 2 #define LIBC_AIO_H 3 3 #include <aio.h> 4 4 5 + #ifdef __cplusplus 5 6 extern "C" 6 7 { 8 + #endif 7 9 8 10 #define DARWIN_LIO_NOWAIT 0x1 9 11 #define DARWIN_LIO_WAIT 0x2 ··· 28 30 int __darwin_aio_cancel(int fd, struct aiocb *aiocbp); // flags 29 31 int __darwin_lio_listio(int mode, struct aiocb *const aiocb_list[], int nitems, struct sigevent *sevp); // flags 30 32 33 + #ifdef __cplusplus 31 34 } 35 + #endif 32 36 33 37 #endif 34 38
+4
src/libSystem/libc/arch.h
··· 11 11 const char* description; 12 12 }; 13 13 14 + #ifdef __cplusplus 14 15 extern "C" 15 16 { 17 + #endif 16 18 17 19 const NXArchInfo* NXGetAllArchInfos(); 18 20 const NXArchInfo* NXGetLocalArchInfo(); 19 21 const NXArchInfo* NXGetArchInfoFromName(const char *name); 20 22 23 + #ifdef __cplusplus 21 24 } 25 + #endif 22 26 23 27 #endif 24 28
+4
src/libSystem/libc/dir.h
··· 25 25 }; 26 26 #pragma pack() 27 27 28 + #ifdef __cplusplus 28 29 extern "C" 29 30 { 31 + #endif 30 32 31 33 darwin_dirent64* __darwin_readdir64(DIR* dirp) asm("__darwin_readdir$INODE64"); 32 34 darwin_dirent* __darwin_readdir(DIR* dirp); ··· 55 57 int __darwin_versionsort(const void *a, const void *b); 56 58 int __darwin_versionsort64(const void *a, const void *b) asm("__darwin_versionsort$INODE64"); 57 59 60 + #ifdef __cplusplus 58 61 } 62 + #endif 59 63 60 64 #endif
+4
src/libSystem/libc/exec.h
··· 1 1 #ifndef LIBC_EXEC_H 2 2 #define LIBC_EXEC_H 3 3 4 + #ifdef __cplusplus 4 5 extern "C" 5 6 { 7 + #endif 6 8 7 9 int __darwin_execl(const char *path, const char *arg, ...); 8 10 int __darwin_execlp(const char *file, const char *arg, ...); ··· 11 13 int __darwin_execvp(const char *file, char *const argv[]); 12 14 int __darwin_execvpe(const char *file, char *const argv[], char *const envp[]); 13 15 16 + #ifdef __cplusplus 14 17 } 18 + #endif 15 19 16 20 #endif
+9
src/libSystem/libc/fopsmisc.cpp
··· 11 11 char *__darwin_realpath(const char *path, char *resolved_path) 12 12 { 13 13 TRACE2(path, resolved_path); 14 + bool ownbuf = false; 15 + 14 16 if (!path) 15 17 { 16 18 errno = DARWIN_EINVAL; ··· 20 22 path = translatePathCI(path); 21 23 22 24 if (!resolved_path) // DARWIN_EXTSN 25 + { 26 + ownbuf = true; 23 27 resolved_path = static_cast<char*>(malloc(DARWIN_MAXPATHLEN)); 28 + } 24 29 25 30 char* rv = realpath(path, resolved_path); 26 31 if (!rv) 32 + { 33 + if (ownbuf) 34 + free(resolved_path); 27 35 errnoOut(); 36 + } 28 37 29 38 return rv; 30 39 }
+4 -1
src/libSystem/libc/fopsmisc.h
··· 1 1 #ifndef LIBC_FOPSMISC_H 2 2 #define LIBC_FOPSMISC_H 3 3 4 + #ifdef __cplusplus 4 5 extern "C" 5 6 { 7 + #endif 6 8 7 9 char *__darwin_realpath(const char *path, char *resolved_path); 8 10 int __darwin_mkstemp(char *tpl); ··· 10 12 char *__darwin_mktemp(char *tpl); 11 13 char *__darwin_tempnam(const char *dir, const char *pfx); 12 14 13 - 15 + #ifdef __cplusplus 14 16 } 17 + #endif 15 18 16 19 #endif 17 20
+4
src/libSystem/libc/getpwent.h
··· 2 2 #define LIBC_GETPWENT_H 3 3 #include <sys/types.h> 4 4 5 + #ifdef __cplusplus 5 6 extern "C" 6 7 { 8 + #endif 7 9 8 10 struct __darwin_passwd 9 11 { ··· 32 34 // void __darwin_setpwent(); 33 35 // void __darwin_endpwent(); 34 36 37 + #ifdef __cplusplus 35 38 } 39 + #endif 36 40 37 41 38 42 #endif
+17
src/thin/CMakeLists.txt
··· 1 + project(thin) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + if(COMMAND cmake_policy) 5 + cmake_policy(SET CMP0003 NEW) 6 + endif(COMMAND cmake_policy) 7 + 8 + add_library(AppKit SHARED) 9 + target_link_libraries(AppKit -lgnustep-gui -lopal) 10 + SET_TARGET_PROPERTIES(AppKit PROPERTIES LINKER_LANGUAGE C) 11 + 12 + add_library(Cocoa SHARED) 13 + target_link_libraries(Cocoa -lgnustep-gui -lopal) 14 + SET_TARGET_PROPERTIES(Cocoa PROPERTIES LINKER_LANGUAGE C) 15 + 16 + install(TARGETS Cocoa AppKit DESTINATION "lib${SUFFIX}/darling") 17 +
+30
tests/CMakeLists.txt
··· 1 + project(runtest) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + if(COMMAND cmake_policy) 5 + cmake_policy(SET CMP0003 NEW) 6 + endif(COMMAND cmake_policy) 7 + 8 + #if (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 9 + # message(FATAL_ERROR "Clang is the only supported compiler.") 10 + #endif (NOT "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang") 11 + 12 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC") 13 + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fPIC") 14 + 15 + set(runtest_SRCS 16 + runtest.cpp 17 + termcolor.cpp 18 + pstream.cpp 19 + boostxml.cpp 20 + timer.cpp 21 + ) 22 + 23 + add_executable(runtest ${runtest_SRCS}) 24 + target_link_libraries(runtest sshcxx) 25 + 26 + add_subdirectory(libsshcxx) 27 + add_dependencies(runtest sshcxx) 28 + 29 + #install(TARGETS runtest DESTINATION "lib${SUFFIX}/darling") 30 +
+40
tests/boostxml.cpp
··· 1 + #include "boostxml.h" 2 + 3 + boostxml::boostxml() 4 + { 5 + m_xml << "<TestLog>\n"; 6 + m_xml << "\t<TestSuite name=\"Darling\">\n"; 7 + } 8 + 9 + void boostxml::addOK(const std::string& path, int time) 10 + { 11 + m_xml << "\t\t<TestCase name=\"" << extractName(path) << "\">\n"; 12 + m_xml << "\t\t\t<TestingTime>" << time << "</TestingTime>\n"; 13 + m_xml << "\t\t</TestCase>\n"; 14 + } 15 + 16 + void boostxml::addFailure(const std::string& path, int time, const std::string& error) 17 + { 18 + m_xml << "\t\t<TestCase name=\"" << extractName(path) << "\">\n"; 19 + m_xml << "\t\t\t<TestingTime>" << time << "</TestingTime>\n"; 20 + m_xml << "\t\t\t<Error file=\"" << path << "\" line=\"0\">\n"; 21 + m_xml << "<![CDATA[" << error << "]]>\n"; 22 + m_xml << "\t\t\t</Error>\n"; 23 + m_xml << "\t\t</TestCase>\n"; 24 + } 25 + 26 + std::string boostxml::str() 27 + { 28 + m_xml << "\t</TestSuite>\n</TestLog>\n"; 29 + return m_xml.str(); 30 + } 31 + 32 + std::string boostxml::extractName(const std::string& path) 33 + { 34 + size_t pos = path.rfind('/'); 35 + if (pos == std::string::npos) 36 + return path; 37 + else 38 + return path.substr(pos+1); 39 + } 40 +
+21
tests/boostxml.h
··· 1 + #ifndef BOOSTXML_H 2 + #define BOOSTXML_H 3 + #include <sstream> 4 + #include <string> 5 + 6 + class boostxml 7 + { 8 + public: 9 + boostxml(); 10 + std::string str(); 11 + 12 + void addOK(const std::string& path, int time); 13 + void addFailure(const std::string& path, int time, const std::string& error); 14 + private: 15 + static std::string extractName(const std::string& path); 16 + private: 17 + std::stringstream m_xml; 18 + }; 19 + 20 + #endif 21 +
+29
tests/exceptions.h
··· 1 1 #ifndef __EXCEPTIONS_H 2 2 #define __EXCEPTIONS_H 3 3 #include <stdexcept> 4 + #include <sstream> 4 5 5 6 class compile_error : public std::runtime_error 6 7 { ··· 28 29 const std::string& remote() const { return m_remote; } 29 30 private: 30 31 std::string m_local, m_remote; 32 + }; 33 + 34 + class nonzero_exit_error : public std::exception 35 + { 36 + public: 37 + nonzero_exit_error(bool remote, const std::string& output) 38 + : m_remote(remote), m_output(output) 39 + { 40 + std::stringstream ss; 41 + ss << "Non-zero exit status from "; 42 + if (m_remote) 43 + ss << "remotely"; 44 + else 45 + ss << "locally"; 46 + ss << " run binary"; 47 + m_msg = ss.str(); 48 + } 49 + 50 + bool remote() const { return m_remote; } 51 + const std::string& output() const { return m_output; } 52 + 53 + virtual const char* what() const throw() override 54 + { 55 + return m_msg.c_str(); 56 + } 57 + private: 58 + bool m_remote; 59 + std::string m_output, m_msg; 31 60 }; 32 61 33 62 #endif
+46 -4
tests/runtest.cpp
··· 5 5 #include "termcolor.h" 6 6 #include "pstream.h" 7 7 #include "exceptions.h" 8 + #include "boostxml.h" 9 + #include "timer.h" 8 10 #include <memory> 9 11 #include <stdexcept> 10 12 #include <sstream> ··· 35 37 36 38 bits(argv[0]); 37 39 40 + boostxml bxml; 41 + 38 42 try 39 43 { 40 44 std::cout << "Opening SSH connection...\n"; ··· 48 52 g_sftp.reset(g_ssh->sftpChannel()); 49 53 50 54 int failures = 0; 55 + int i = 1; 56 + timer tm; 57 + 58 + if (argc >= 2 && strncmp(argv[1], "--xml=", 6) == 0) 59 + i++; 51 60 52 - for (int i = 1; i < argc; i++) 61 + for (; i < argc; i++) 53 62 { 63 + time_t timeStart, timeEnd; 54 64 try 55 65 { 56 66 termcolor::set(termcolor::WHITE, termcolor::BLACK, termcolor::BRIGHT); ··· 59 69 std::cout << "=======\n"; 60 70 termcolor::reset(); 61 71 72 + tm.start(); 73 + 62 74 runTest(argv[i]); 75 + bxml.addOK(argv[i], tm.stop()); 63 76 64 77 termcolor::set(termcolor::GREEN, termcolor::BLACK, termcolor::BRIGHT); 65 78 std::cout << "*** Test OK!\n"; ··· 72 85 termcolor::reset(); 73 86 74 87 std::cerr << e.what() << std::endl; 88 + bxml.addFailure(argv[i], tm.stop(), e.what()); 75 89 76 90 failures++; 77 91 } ··· 90 104 std::cerr << "Local output:\n"; 91 105 termcolor::reset(); 92 106 std::cerr << e.local(); 107 + 108 + std::stringstream ss; 109 + ss << "Test outputs differ!\n\n"; 110 + ss << "Remote output:\n"; 111 + ss << e.remote() << "\n\n"; 112 + ss << "Local output:\n"; 113 + ss << e.local(); 114 + bxml.addFailure(argv[i], tm.stop(), ss.str()); 93 115 94 116 failures++; 95 117 } 118 + catch (const nonzero_exit_error& e) 119 + { 120 + termcolor::setBright(termcolor::RED); 121 + std::cerr << "*** Non-zero exit status!\n"; 122 + termcolor::reset(); 123 + 124 + termcolor::setBright(termcolor::WHITE); 125 + std::cerr << ((e.remote()) ? "remote" : "local" ); 126 + std::cerr << " test output leading to the error:\n"; 127 + termcolor::reset(); 128 + std::cerr << e.output(); 129 + 130 + std::stringstream ss; 131 + ss << "Non-zero exit status (" << ((e.remote() ? "remote" : "local")) << ")\n"; 132 + ss << e.output(); 133 + 134 + bxml.addFailure(argv[i], tm.stop(), ss.str()); 135 + 136 + failures++; 137 + } 96 138 } 97 139 98 140 if (!failures) 99 141 { 100 142 termcolor::setBright(termcolor::GREEN); 101 - std::cout << "ALL OK!"; 143 + std::cout << "ALL OK!\n"; 102 144 } 103 145 else 104 146 { ··· 169 211 rv = g_ssh->runCommand(binary, out, err); 170 212 171 213 if (rv) 172 - throw std::runtime_error("Non-zero exit status from remotely run binary"); 214 + throw nonzero_exit_error(true, out); 173 215 174 216 std::cout << "Downloading...\n"; 175 217 // download the Mach-O executable ··· 185 227 rv = loc->wait(); 186 228 187 229 if (rv) 188 - throw std::runtime_error("Non-zero exit status from locally run binary"); 230 + throw nonzero_exit_error(false, locOut.str()); 189 231 190 232 if (locOut.str() != out) 191 233 throw different_output_error(out, locOut.str());
+32
tests/src/fcntl.c
··· 1 + #include <stdio.h> 2 + #include <stdlib.h> 3 + #include <fcntl.h> 4 + #include <sys/types.h> 5 + #include <sys/stat.h> 6 + #include <sys/param.h> 7 + #include <string.h> 8 + #include <assert.h> 9 + 10 + void test_getpath(); 11 + 12 + int main() 13 + { 14 + test_getpath(); 15 + return 0; 16 + } 17 + 18 + void test_getpath() 19 + { 20 + char path[255] = "/tmp/fcntl.XXXXXX"; 21 + char fpath[MAXPATHLEN]; 22 + mkstemp(path); 23 + 24 + int fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666); 25 + fcntl(fd, F_GETPATH, fpath); 26 + 27 + close(fd); 28 + 29 + assert(strcmp(realpath(path, 0), realpath(fpath, 0)) == 0); 30 + remove(path); 31 + } 32 +
+12
tests/timer.cpp
··· 1 + #include "timer.h" 2 + 3 + void timer::start() 4 + { 5 + m_start = ::time(nullptr); 6 + } 7 + 8 + int timer::stop() 9 + { 10 + return ::time(nullptr) - m_start; 11 + } 12 +
+15
tests/timer.h
··· 1 + #ifndef TIMER_H 2 + #define TIMER_H 3 + #include <ctime> 4 + 5 + class timer 6 + { 7 + public: 8 + void start(); 9 + int stop(); 10 + private: 11 + time_t m_start; 12 + }; 13 + 14 + #endif 15 +