<commit_before>/*
 * Copyright (C) 2014 <NAME> <ludwig.ortmann@fu-berlin.de>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup tests
 * @{
 *
 * @file
 * @brief Hwtimer test application
 *
 * @author      <NAME> <ludwig.ortmann@fu-berlin.de>
 *
 * @}
 */

#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

#include "board_uart0.h"
#include "posix_io.h"
#include "hwtimer.h"
#include "thread.h"

int main(void)
{
    puts("This is a regression test for a race condition in hwtimer_wait.");
    puts("When the race condition is hit, the timer will wait for a very very long time...");

    for (unsigned long r = 10000; r > 0; r--) {
        for (unsigned long i = 256; i; i = i >> 1) {
            hwtimer_wait(i);
        }
    }
    puts("success");
    return 0;
}<commit_msg>tests: print expected duration in hwtimer_wait<commit_after>/*
 * Copyright (C) 2014 <NAME> <ludwig.ortmann@fu-berlin.de>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup tests
 * @{
 *
 * @file
 * @brief Hwtimer test application
 *
 * @author      <NAME> <ludwig.ortmann@fu-berlin.de>
 *
 * @}
 */

#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

#include "board_uart0.h"
#include "posix_io.h"
#include "hwtimer.h"
#include "thread.h"

int main(void)
{
    puts("This is a regression test for a race condition in hwtimer_wait.");
    puts("When the race condition is hit, the timer will wait for a very very long time.");

    int iterations = 10000;
    int start_duration = 256;

    long duration = iterations * (
            /* geometric series */
            (1 - pow(2,(log2(start_duration) + 1)))
            / (1 - 2)
            );
    printf("The test should take about %li sec.\n", (HWTIMER_TICKS_TO_US(duration)/1000000));

    for (unsigned long r = iterations; r > 0; r--) {
        for (unsigned long i = start_duration; i; i = i >> 1) {
            hwtimer_wait(i);
        }
    }
    puts("success");

    return 0;
}
{'fraction_non_alphanumeric': 0.13674832962138084, 'fraction_numerical': 0.02182628062360802, 'mean_word_length': 2.7308970099667773, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3712286', 'n_tokens_mistral': 801, 'n_tokens_neox': 760, 'n_words': 249}