Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move c_sleep to helpers.h and misc_tools.h #490

Merged
merged 1 commit into from
Mar 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@

#include "helpers.h"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

#define NUM_PORTS 3

static uint16_t ports[NUM_PORTS] = {1234, 33445, 25643};
Expand Down
9 changes: 0 additions & 9 deletions auto_tests/conference_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@

#include "helpers.h"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif


#define NUM_GROUP_TOX 32

static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length,
Expand Down
8 changes: 0 additions & 8 deletions auto_tests/dht_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,6 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port)
{
}


#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

#define NUM_DHT_FRIENDS 20

START_TEST(test_DHT_test)
Expand Down
8 changes: 8 additions & 0 deletions auto_tests/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
#include <check.h>
#include <stdio.h>

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*(x))
#endif

#define DEFTESTCASE(NAME) \
TCase *tc_##NAME = tcase_create(#NAME); \
tcase_add_test(tc_##NAME, test_##NAME); \
Expand Down
7 changes: 0 additions & 7 deletions auto_tests/onion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@

#include "helpers.h"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

static void do_onion(Onion *onion)
{
networking_poll(onion->net, NULL);
Expand Down
8 changes: 0 additions & 8 deletions auto_tests/save_friend_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@
#include <stdlib.h>
#include <string.h>

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

struct test_data {
uint8_t name[TOX_MAX_NAME_LENGTH];
uint8_t status_message[TOX_MAX_STATUS_MESSAGE_LENGTH];
Expand Down
8 changes: 0 additions & 8 deletions auto_tests/tox_many_tcp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@

#include "helpers.h"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

/* The Travis-CI container responds poorly to ::1 as a localhost address
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
#ifdef FORCE_TESTS_IPV6
Expand Down
8 changes: 0 additions & 8 deletions auto_tests/tox_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@

#include "helpers.h"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
{
if (*((uint32_t *)userdata) != 974536) {
Expand Down
8 changes: 0 additions & 8 deletions auto_tests/tox_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@

#include "helpers.h"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

/* The Travis-CI container responds poorly to ::1 as a localhost address
* You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
#ifdef FORCE_TESTS_IPV6
Expand Down
9 changes: 0 additions & 9 deletions auto_tests/toxav_basic_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
#include "../toxcore/util.h"


#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif


#define TEST_REGULAR_AV 1
#define TEST_REGULAR_A 1
#define TEST_REGULAR_V 1
Expand Down
8 changes: 1 addition & 7 deletions auto_tests/toxav_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@
#include "../toxcore/tox.h"
#include "../toxcore/util.h"

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(1*x)
#else
#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
#include <pthread.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif


typedef struct {
bool incoming;
uint32_t state;
Expand Down
9 changes: 0 additions & 9 deletions other/DHT_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@
#define DHT_MOTD "This is a test motd"
#endif

/* Sleep function (x = milliseconds) */
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#else
#include <arpa/inet.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#endif

#define PORT 33445


Expand Down
10 changes: 1 addition & 9 deletions testing/DHT_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,8 @@

#include <string.h>

//Sleep function (x = milliseconds)
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)

#define c_sleep(x) Sleep(1*x)

#else
#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
#include <arpa/inet.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)

#endif

#define PORT 33445
Expand Down
9 changes: 1 addition & 8 deletions testing/Messenger_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,8 @@
#include "../toxcore/Messenger.h"
#include "misc_tools.c"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)

#define c_sleep(x) Sleep(1*x)

#else
#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
#include <arpa/inet.h>
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#define PORT 33445

#endif

Expand Down
2 changes: 1 addition & 1 deletion testing/av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extern "C" {
#include <time.h>
#include <unistd.h>

#define c_sleep(x) usleep(1000*x)
#define c_sleep(x) usleep(1000*(x))


#define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X)
Expand Down
9 changes: 0 additions & 9 deletions testing/dns3_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
#include "../toxdns/toxdns.h"
#include "misc_tools.c"

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)

#define c_sleep(x) Sleep(1*x)

#else
#define c_sleep(x) usleep(1000*x)

#endif

static uint32_t create_packet(uint8_t *packet, uint8_t *string, uint8_t str_len, uint8_t id)
{
memset(packet, 0, str_len + 13 + 16);
Expand Down
9 changes: 9 additions & 0 deletions testing/misc_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
#include <stdlib.h>
#include <string.h>

//Sleep function (x = milliseconds)
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*(x))
#endif

// You are responsible for freeing the return value!
uint8_t *hex_string_to_bin(const char *hex_string)
{
Expand Down
4 changes: 2 additions & 2 deletions testing/nTox.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#include <time.h>

#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#define c_sleep(x) Sleep(1*x)
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#define c_sleep(x) usleep(1000*x)
#define c_sleep(x) usleep(1000*(x))
#endif

static void new_lines(char const *line);
Expand Down
3 changes: 0 additions & 3 deletions testing/tox_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
#include <pty.h>
#endif
#include <fcntl.h>
#include <unistd.h>

#define c_sleep(x) usleep(1000*x)

static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata)
{
Expand Down
3 changes: 0 additions & 3 deletions testing/tox_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
#include "../toxcore/tox.h"
#include "misc_tools.c"

#include <unistd.h>
#define c_sleep(x) usleep(1000*x)

#include <arpa/inet.h>
#include <dirent.h>
#include <netinet/in.h>
Expand Down