summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDavid Zero <zero@cpp.edu>2016-12-02 04:37:23 -0800
committerDavid Zero <zero@cpp.edu>2017-01-04 13:44:39 -0800
commitf3469070fe899e8e4fd88665386a55bad9f77cd8 (patch)
treec24743d266d3a8593792ef3e8661006cb283368a /testing
parent535b8238fd191710e1e8864f302fba5a02f52b1d (diff)
Portability fixes
- CFLAG gnu99 was changed to c99. - CXXFLAG c++98 was changed to c++11. - CFLAG -pedantic-errors was added so that non-ISO C now throws errors. - _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3 and c99 definitions in modules that required them. - Fixed tests (and bootstrap daemon logging) that were failing due to the altered build flags. - Avoid string suffix misinterpretation; explicit narrowing conversion. - Misc. additions to .gitignore to make sure build artifacts don't wind up in version control.
Diffstat (limited to 'testing')
-rw-r--r--testing/DHT_test.c2
-rw-r--r--testing/Messenger_test.c2
-rw-r--r--testing/av_test.c2
-rw-r--r--testing/irc_syncbot.c9
-rw-r--r--testing/misc_tools.c1
-rw-r--r--testing/tox_shell.c2
-rw-r--r--testing/tox_sync.c11
7 files changed, 24 insertions, 5 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index c994f543..6d20d550 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -27,6 +27,8 @@
27 * 27 *
28 */ 28 */
29 29
30#define _XOPEN_SOURCE 600
31
30#ifdef HAVE_CONFIG_H 32#ifdef HAVE_CONFIG_H
31#include "config.h" 33#include "config.h"
32#endif 34#endif
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index 4fd81649..695c50ae 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -37,6 +37,8 @@
37 * 37 *
38 */ 38 */
39 39
40#define _XOPEN_SOURCE 600
41
40#ifdef HAVE_CONFIG_H 42#ifdef HAVE_CONFIG_H
41#include "config.h" 43#include "config.h"
42#endif 44#endif
diff --git a/testing/av_test.c b/testing/av_test.c
index 7418a15a..aeb661be 100644
--- a/testing/av_test.c
+++ b/testing/av_test.c
@@ -22,6 +22,8 @@
22 * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio 22 * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio
23 */ 23 */
24 24
25#define _XOPEN_SOURCE 600
26
25#ifdef __cplusplus 27#ifdef __cplusplus
26extern "C" { 28extern "C" {
27#endif 29#endif
diff --git a/testing/irc_syncbot.c b/testing/irc_syncbot.c
index affc0296..b63b6151 100644
--- a/testing/irc_syncbot.c
+++ b/testing/irc_syncbot.c
@@ -1,3 +1,4 @@
1#define _XOPEN_SOURCE 600
1 2
2#include <stdint.h> 3#include <stdint.h>
3#include <stdio.h> 4#include <stdio.h>
@@ -34,8 +35,8 @@ static uint16_t port = 6667;
34 35
35static int sock; 36static int sock;
36 37
37#define SERVER_CONNECT "NICK "IRC_NAME"\nUSER "IRC_NAME" 8 * :"IRC_NAME"\n" 38#define SERVER_CONNECT "NICK " IRC_NAME "\nUSER " IRC_NAME " 8 * :" IRC_NAME "\n"
38#define CHANNEL_JOIN "JOIN "IRC_CHANNEL"\n" 39#define CHANNEL_JOIN "JOIN " IRC_CHANNEL "\n"
39 40
40/* In toxcore/network.c */ 41/* In toxcore/network.c */
41uint64_t current_time_monotonic(void); 42uint64_t current_time_monotonic(void);
@@ -131,8 +132,8 @@ static void copy_groupmessage(Tox *tox, uint32_t groupnumber, uint32_t friendgro
131 uint8_t sendbuf[2048]; 132 uint8_t sendbuf[2048];
132 uint16_t send_len = 0; 133 uint16_t send_len = 0;
133 134
134 memcpy(sendbuf, "PRIVMSG "IRC_CHANNEL" :", sizeof("PRIVMSG "IRC_CHANNEL" :")); 135 memcpy(sendbuf, "PRIVMSG " IRC_CHANNEL " :", sizeof("PRIVMSG " IRC_CHANNEL " :"));
135 send_len += sizeof("PRIVMSG "IRC_CHANNEL" :") - 1; 136 send_len += sizeof("PRIVMSG " IRC_CHANNEL " :") - 1;
136 memcpy(sendbuf + send_len, name, namelen); 137 memcpy(sendbuf + send_len, name, namelen);
137 send_len += namelen; 138 send_len += namelen;
138 sendbuf[send_len] = ':'; 139 sendbuf[send_len] = ':';
diff --git a/testing/misc_tools.c b/testing/misc_tools.c
index c1292ed8..30c813ca 100644
--- a/testing/misc_tools.c
+++ b/testing/misc_tools.c
@@ -29,6 +29,7 @@
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <string.h> 31#include <string.h>
32#include <strings.h>
32 33
33#ifdef TOX_DEBUG 34#ifdef TOX_DEBUG
34#include <assert.h> 35#include <assert.h>
diff --git a/testing/tox_shell.c b/testing/tox_shell.c
index 18aad9c7..d5de3e67 100644
--- a/testing/tox_shell.c
+++ b/testing/tox_shell.c
@@ -26,6 +26,8 @@
26 * 26 *
27 */ 27 */
28 28
29#define _XOPEN_SOURCE 600
30
29#ifdef HAVE_CONFIG_H 31#ifdef HAVE_CONFIG_H
30#include "config.h" 32#include "config.h"
31#endif 33#endif
diff --git a/testing/tox_sync.c b/testing/tox_sync.c
index 0c91abfd..6ac3dcf0 100644
--- a/testing/tox_sync.c
+++ b/testing/tox_sync.c
@@ -28,6 +28,8 @@
28 * 28 *
29 */ 29 */
30 30
31#define _XOPEN_SOURCE 600
32
31#ifdef HAVE_CONFIG_H 33#ifdef HAVE_CONFIG_H
32#include "config.h" 34#include "config.h"
33#endif 35#endif
@@ -42,6 +44,7 @@
42#include <dirent.h> 44#include <dirent.h>
43#include <netinet/in.h> 45#include <netinet/in.h>
44#include <stdio.h> 46#include <stdio.h>
47#include <sys/stat.h>
45 48
46#define NUM_FILE_SENDERS 256 49#define NUM_FILE_SENDERS 256
47typedef struct { 50typedef struct {
@@ -297,6 +300,7 @@ int main(int argc, char *argv[])
297 memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4])); 300 memcpy(path, argv[argvoffset + 4], strlen(argv[argvoffset + 4]));
298 DIR *d; 301 DIR *d;
299 struct dirent *dir; 302 struct dirent *dir;
303 struct stat statbuf;
300 uint8_t notconnected = 1; 304 uint8_t notconnected = 1;
301 305
302 while (1) { 306 while (1) {
@@ -310,7 +314,12 @@ int main(int argc, char *argv[])
310 314
311 if (d) { 315 if (d) {
312 while ((dir = readdir(d)) != NULL) { 316 while ((dir = readdir(d)) != NULL) {
313 if (dir->d_type == DT_REG) { 317 char filepath[strlen(path) + strlen(dir->d_name) + 1];
318 memcpy(filepath, path, strlen(path));
319 memcpy(filepath + strlen(path), dir->d_name, strlen(dir->d_name) + 1);
320 stat(filepath, &statbuf);
321
322 if (S_ISREG(statbuf.st_mode)) {
314 char fullpath[1024]; 323 char fullpath[1024];
315 324
316 if (path[strlen(path) - 1] == '/') { 325 if (path[strlen(path) - 1] == '/') {