mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 09:32:44 +01:00
tests: use astyle to adopt current code style guide
This commit is contained in:
parent
5ef2b04dd0
commit
66e7762630
@ -33,7 +33,8 @@ int main(void)
|
||||
for (int i = 0; i < lenA; i++) {
|
||||
if (bloom_check(bloom, (const uint8_t *) A[i], strlen(A[i]))) {
|
||||
in++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
not_in++;
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ int main(void)
|
||||
genrand_init(myseed);
|
||||
|
||||
unsigned long t1 = hwtimer_now();
|
||||
|
||||
for (int i = 0; i < lenB; i++) {
|
||||
buf_fill(buf, BUF_SIZE);
|
||||
buf[0] = MAGIC_B;
|
||||
@ -55,6 +56,7 @@ int main(void)
|
||||
(uint8_t *) buf,
|
||||
BUF_SIZE * sizeof(uint32_t) / sizeof(uint8_t));
|
||||
}
|
||||
|
||||
unsigned long t2 = hwtimer_now();
|
||||
printf("adding %d elements took %" PRIu32 "ms\n", lenB,
|
||||
(uint32_t) HWTIMER_TICKS_TO_US(t2 - t1) / 1000);
|
||||
@ -63,6 +65,7 @@ int main(void)
|
||||
int not_in = 0;
|
||||
|
||||
unsigned long t3 = hwtimer_now();
|
||||
|
||||
for (int i = 0; i < lenA; i++) {
|
||||
buf_fill(buf, BUF_SIZE);
|
||||
buf[0] = MAGIC_A;
|
||||
@ -71,10 +74,12 @@ int main(void)
|
||||
(uint8_t *) buf,
|
||||
BUF_SIZE * sizeof(uint32_t) / sizeof(uint8_t))) {
|
||||
in++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
not_in++;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long t4 = hwtimer_now();
|
||||
printf("checking %d elements took %" PRIu32 "ms\n", lenA,
|
||||
(uint32_t) HWTIMER_TICKS_TO_US(t4 - t3) / 1000);
|
||||
|
@ -5,12 +5,15 @@
|
||||
int main(void)
|
||||
{
|
||||
double x = 1234567. / 1024., z;
|
||||
|
||||
while (1) {
|
||||
x += 0.1;
|
||||
z = x - floor(x);
|
||||
|
||||
if (z >= 1) {
|
||||
putchar('+');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
putchar('-');
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
int main(void)
|
||||
{
|
||||
printf("when the race condition is hit, hwtimer will wait a very very long time...\n");
|
||||
|
||||
while (1) {
|
||||
for (unsigned long i = 256; i; i = i >> 1) {
|
||||
printf("wait %lu\n", i);
|
||||
|
@ -18,9 +18,11 @@ void busy_thread(void)
|
||||
printf("busy_thread starting\n");
|
||||
|
||||
i = 0;
|
||||
|
||||
while (busy) {
|
||||
k = j = ++i;
|
||||
}
|
||||
|
||||
printf("i: %i\n", i);
|
||||
printf("j: %i\n", j);
|
||||
printf("k: %i\n", k);
|
||||
|
@ -32,7 +32,8 @@ uint8_t receiving = 1;
|
||||
unsigned int last_seq = 0, missed_cnt = 0;
|
||||
int first = -1;
|
||||
|
||||
void radio(void) {
|
||||
void radio(void)
|
||||
{
|
||||
msg_t m;
|
||||
radio_packet_t *p;
|
||||
unsigned int tmp = 0, cur_seq = 0;
|
||||
@ -40,27 +41,34 @@ void radio(void) {
|
||||
msg_init_queue(msg_q, RCV_BUFFER_SIZE);
|
||||
|
||||
puts("Start receiving");
|
||||
|
||||
while (receiving) {
|
||||
msg_receive(&m);
|
||||
|
||||
if (m.type == PKT_PENDING) {
|
||||
p = (radio_packet_t *) m.content.ptr;
|
||||
|
||||
if ((p->src == SENDER_ADDR) && (p->length == PACKET_SIZE)) {
|
||||
puts("received");
|
||||
cur_seq = (p->data[0] << 8) + p->data[1];
|
||||
|
||||
if (first < 0) {
|
||||
first = cur_seq;
|
||||
}
|
||||
else {
|
||||
tmp = cur_seq - last_seq;
|
||||
|
||||
if (last_seq && (tmp > 1)) {
|
||||
missed_cnt += (tmp - 1);
|
||||
}
|
||||
}
|
||||
|
||||
last_seq = cur_seq;
|
||||
}
|
||||
else {
|
||||
printf("sender was %i\n", p->src);
|
||||
}
|
||||
|
||||
p->processing--;
|
||||
}
|
||||
else if (m.type == ENOBUFFER) {
|
||||
@ -72,7 +80,8 @@ void radio(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void sender(void) {
|
||||
void sender(void)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
msg_t mesg;
|
||||
transceiver_command_t tcmd;
|
||||
@ -88,6 +97,7 @@ void sender(void) {
|
||||
p.dst = 0;
|
||||
|
||||
puts("Start sending packets");
|
||||
|
||||
while (1) {
|
||||
/* filling uint8_t buffer with uint16_t sequence number */
|
||||
snd_buffer[0] = (i & 0xFF00) >> 8;
|
||||
|
@ -22,14 +22,16 @@
|
||||
|
||||
#define PORT (1234)
|
||||
|
||||
void init_local_address(uint16_t r_addr) {
|
||||
void init_local_address(uint16_t r_addr)
|
||||
{
|
||||
ipv6_addr_t std_addr;
|
||||
ipv6_addr_init(&std_addr, 0xabcd, 0xef12, 0, 0, 0x1034, 0x00ff, 0xfe00,
|
||||
r_addr);
|
||||
sixlowpan_lowpan_adhoc_init(TRANSCEIVER, &std_addr, r_addr);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
int sockfd, res;
|
||||
struct sockaddr_in6 my_addr, their_addr = {
|
||||
.sin6_family = AF_INET6,
|
||||
@ -40,11 +42,19 @@ int main(void) {
|
||||
#endif
|
||||
.sin6_flowinfo = 0,
|
||||
#if R_ADDR == 1
|
||||
.sin6_addr = {{{0xab, 0xcd, 0xef, 0x12, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x34, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x02}}},
|
||||
.sin6_addr = {{{
|
||||
0xab, 0xcd, 0xef, 0x12, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x34, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x02
|
||||
}
|
||||
}
|
||||
},
|
||||
#else
|
||||
.sin6_addr = {{{0xab, 0xcd, 0xef, 0x12, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x34, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01}}},
|
||||
.sin6_addr = {{{
|
||||
0xab, 0xcd, 0xef, 0x12, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x34, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x01
|
||||
}
|
||||
}
|
||||
},
|
||||
#endif
|
||||
.sin6_scope_id = 0,
|
||||
};
|
||||
@ -59,6 +69,7 @@ int main(void) {
|
||||
|
||||
sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
res = bind(sockfd, (struct sockaddr *)&my_addr, sizeof(my_addr));
|
||||
|
||||
if (res < 0) {
|
||||
perror("Socket could not be bind");
|
||||
return 1;
|
||||
@ -73,12 +84,15 @@ int main(void) {
|
||||
res = recvfrom(sockfd, buffer, strlen(buffer), 0,
|
||||
(struct sockaddr *)&their_addr,
|
||||
&their_len);
|
||||
|
||||
if (their_addr.sin6_addr.uint8[15] != 1) {
|
||||
fprintf(stderr, "Wrong sender address: %d\n", their_addr.sin6_addr.uint8[11]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Port: %d\n", their_addr.sin6_port);
|
||||
#endif
|
||||
|
||||
if (res < 0) {
|
||||
perror("Message error");
|
||||
return 1;
|
||||
|
@ -21,15 +21,19 @@ sem_t s;
|
||||
static void test1_second_thread(void)
|
||||
{
|
||||
puts("second: sem_trywait");
|
||||
|
||||
if (sem_trywait(&s) == 0) {
|
||||
puts("second: sem_trywait failed");
|
||||
}
|
||||
|
||||
puts("second: sem_trywait done with == 0");
|
||||
|
||||
puts("second: wait for post");
|
||||
|
||||
if (sem_wait(&s) != 1) {
|
||||
puts("second: sem_wait failed");
|
||||
}
|
||||
|
||||
puts("second: sem was posted");
|
||||
|
||||
puts("second: end");
|
||||
@ -38,6 +42,7 @@ static void test1_second_thread(void)
|
||||
static void test1(void)
|
||||
{
|
||||
puts("first: sem_init");
|
||||
|
||||
if (sem_init(&s, 0, 0) != 0) {
|
||||
puts("first: sem_init failed");
|
||||
}
|
||||
@ -46,16 +51,20 @@ static void test1(void)
|
||||
int pid = thread_create(test1_thread_stack, KERNEL_CONF_STACKSIZE_PRINTF,
|
||||
PRIORITY_MAIN - 1, CREATE_STACKTEST | CREATE_WOUT_YIELD,
|
||||
test1_second_thread, "second");
|
||||
|
||||
if (pid < 0) {
|
||||
puts("first: thread create failed");
|
||||
}
|
||||
|
||||
puts("first: thread created");
|
||||
|
||||
puts("first: sem_getvalue");
|
||||
int val;
|
||||
|
||||
if (sem_getvalue(&s, &val) != 0 || val != 0) {
|
||||
puts("first: sem_getvalue failed");
|
||||
}
|
||||
|
||||
puts("first: sem_getvalue != 0");
|
||||
|
||||
puts("first: do yield");
|
||||
@ -65,20 +74,25 @@ static void test1(void)
|
||||
/*****************************************************************************/
|
||||
|
||||
puts("first: sem_trywait");
|
||||
|
||||
if (sem_trywait(&s) != -1) {
|
||||
puts("first: sem_trywait failed");
|
||||
}
|
||||
|
||||
puts("first: sem_trywait done");
|
||||
|
||||
puts("first: sem_post");
|
||||
|
||||
if (sem_post(&s) != 1) {
|
||||
puts("first: sem_post failed");
|
||||
}
|
||||
|
||||
puts("first: sem_post done");
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
puts("first: sem_destroy");
|
||||
|
||||
if (sem_destroy(&s) != 0) {
|
||||
puts("first: sem_destroy failed");
|
||||
}
|
||||
@ -96,6 +110,7 @@ char names[SEMAPHORE_TEST_THREADS][16];
|
||||
void test2(void)
|
||||
{
|
||||
puts("first: sem_init");
|
||||
|
||||
if (sem_init(&s, 0, 0) != 0) {
|
||||
puts("first: sem_init failed");
|
||||
}
|
||||
@ -108,13 +123,16 @@ void test2(void)
|
||||
int pid = thread_create(test2_thread_stack[i],
|
||||
KERNEL_CONF_STACKSIZE_PRINTF, priority, CREATE_STACKTEST,
|
||||
priority_sema_thread, names[i]);
|
||||
|
||||
if (pid < 0) {
|
||||
puts("first: thread create failed");
|
||||
}
|
||||
|
||||
printf("first: thread created: %s (%d/%d)\n", names[i], i + 1, SEMAPHORE_TEST_THREADS);
|
||||
}
|
||||
|
||||
puts("------------------------------------------");
|
||||
|
||||
for (int i = 0; i < SEMAPHORE_TEST_THREADS; i++) {
|
||||
printf("post no. %d\n", i);
|
||||
sem_post(&s);
|
||||
|
@ -24,9 +24,11 @@ void sha256_calc(const char *str, const char *expected)
|
||||
printf("Input: %s\n"
|
||||
"Expected: %s\n"
|
||||
"Calculated: ", str, expected);
|
||||
|
||||
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
printf("%02x", hash[i]);
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
|
||||
char t2_stack[STACK_SIZE];
|
||||
|
||||
void second_thread(void) {
|
||||
void second_thread(void)
|
||||
{
|
||||
puts("second thread\n");
|
||||
}
|
||||
|
||||
|
@ -7,17 +7,20 @@
|
||||
char second_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
char third_thread_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
void fourth_thread(void) {
|
||||
void fourth_thread(void)
|
||||
{
|
||||
puts("4th: starting");
|
||||
puts("4th: exiting");
|
||||
}
|
||||
|
||||
void third_thread(void) {
|
||||
void third_thread(void)
|
||||
{
|
||||
puts("3rd: starting");
|
||||
puts("3rd: exiting");
|
||||
}
|
||||
|
||||
void second_thread(void) {
|
||||
void second_thread(void)
|
||||
{
|
||||
puts("2nd: starting");
|
||||
|
||||
if ((thread_create(
|
||||
@ -50,6 +53,7 @@ void second_thread(void) {
|
||||
int main(void)
|
||||
{
|
||||
puts("main: starting");
|
||||
|
||||
if ((thread_create(
|
||||
second_thread_stack,
|
||||
sizeof(second_thread_stack),
|
||||
@ -60,5 +64,6 @@ int main(void)
|
||||
) == -1) {
|
||||
puts("main: Error creating 3rd thread.");
|
||||
}
|
||||
|
||||
puts("main: exiting");
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ void timer_thread(void)
|
||||
tmsg->interval.seconds,
|
||||
tmsg->interval.microseconds,
|
||||
tmsg->msg);
|
||||
|
||||
if (vtimer_set_msg(&tmsg->timer, tmsg->interval, thread_getpid(), tmsg) != 0) {
|
||||
puts("something went wrong");
|
||||
}
|
||||
@ -63,7 +64,8 @@ void timer_thread_local(void)
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int main(void)
|
||||
{
|
||||
msg_t m;
|
||||
int pid = thread_create(
|
||||
timer_stack,
|
||||
@ -90,6 +92,7 @@ int main(void) {
|
||||
"timer local");
|
||||
|
||||
timex_t sleep = timex_set(1, 0);
|
||||
|
||||
while (1) {
|
||||
vtimer_sleep(sleep);
|
||||
msg_send(&m, pid2, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user