summaryrefslogtreecommitdiff
path: root/testsuites/include
diff options
context:
space:
mode:
authorVijay Kumar Banerjee <vijay@rtems.org>2021-02-10 18:20:42 -0700
committerVijay Kumar Banerjee <vijay@rtems.org>2021-03-02 14:29:29 -0700
commit1372fdc88fae999995d34aa0d58361f0e98a53a3 (patch)
tree2f356110ab692e5ea5caf0d25171206846afc986 /testsuites/include
parent1dc3492723fa416e524c08745f4277afde7d1268 (diff)
Add networking01 test from RTEMS testsuites
Diffstat (limited to 'testsuites/include')
-rw-r--r--testsuites/include/buffer_test_io.h21
-rw-r--r--testsuites/include/primode.h27
-rw-r--r--testsuites/include/pritime.h27
-rw-r--r--testsuites/include/test_support.h83
-rw-r--r--testsuites/include/tmacros.h283
-rw-r--r--testsuites/include/tmtests_empty_function.h23
6 files changed, 464 insertions, 0 deletions
diff --git a/testsuites/include/buffer_test_io.h b/testsuites/include/buffer_test_io.h
new file mode 100644
index 0000000..f0eae50
--- /dev/null
+++ b/testsuites/include/buffer_test_io.h
@@ -0,0 +1,21 @@
+/*
+ * Support for running the test output through a buffer
+ */
+
+#ifndef __BUFFER_TEST_IO_h
+#define __BUFFER_TEST_IO_h
+
+#include <rtems/test-info.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TEST_BEGIN() rtems_test_begin(rtems_test_name, TEST_STATE)
+#define TEST_END() rtems_test_end(rtems_test_name)
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/testsuites/include/primode.h b/testsuites/include/primode.h
new file mode 100644
index 0000000..551ae22
--- /dev/null
+++ b/testsuites/include/primode.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 by
+ * Ralf Corsépius, Ulm, Germany. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+/*
+ * Helper macro to print "time_t"
+ */
+
+#ifndef _PRIMODE_H
+#define _PRIMODE_H
+
+#include <inttypes.h>
+#include <rtems/score/cpuopts.h>
+
+#if __RTEMS_SIZEOF_MODE_T__ == 8
+#define PRIomode_t PRIo64
+#elif __RTEMS_SIZEOF_MODE_T__ == 4
+#define PRIomode_t PRIo32
+#else
+#error "unsupported size of mode_t"
+#endif
+
+#endif
diff --git a/testsuites/include/pritime.h b/testsuites/include/pritime.h
new file mode 100644
index 0000000..fea5e62
--- /dev/null
+++ b/testsuites/include/pritime.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 by
+ * Ralf Corsépius, Ulm, Germany. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+/*
+ * Helper macro to print "time_t"
+ */
+
+#ifndef _PRITIME_H
+#define _PRITIME_H
+
+#include <inttypes.h>
+#include <rtems/score/cpuopts.h>
+
+#if __RTEMS_SIZEOF_TIME_T__ == 8
+#define PRIdtime_t PRId64
+#elif __RTEMS_SIZEOF_TIME_T__ == 4
+#define PRIdtime_t PRId32
+#else
+#error "unsupported size of time_t"
+#endif
+
+#endif
diff --git a/testsuites/include/test_support.h b/testsuites/include/test_support.h
new file mode 100644
index 0000000..9c30b39
--- /dev/null
+++ b/testsuites/include/test_support.h
@@ -0,0 +1,83 @@
+/*
+ * COPYRIGHT (c) 1989-2011.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef __TEST_SUPPORT_h
+#define __TEST_SUPPORT_h
+
+#include <stdarg.h>
+#include <rtems.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Return a pointer to the POSIX name that is slightly
+ * beyond the legal limit.
+ */
+const char *Get_Too_Long_Name(void);
+
+/*
+ * Return a pointer to the longest legal POSIX name.
+ */
+const char *Get_Longest_Name(void);
+
+/*
+ * Spin for specified number of ticks. The first tick we spin through is a
+ * partial one.
+ */
+void rtems_test_spin_for_ticks(rtems_interval ticks);
+
+/*
+ * Spin until the next clock tick
+ */
+void rtems_test_spin_until_next_tick( void );
+
+/*********************************************************************/
+/*********************************************************************/
+/************** TMTEST SUPPORT **************/
+/*********************************************************************/
+/*********************************************************************/
+
+/*
+ * Type of method used for timing operations
+ */
+typedef void (*rtems_time_test_method_t)(
+ int iteration,
+ void *argument
+);
+
+/*
+ * Obtain baseline timing information for benchmark tests.
+ */
+void rtems_time_test_measure_operation(
+ const char *description,
+ rtems_time_test_method_t operation,
+ void *argument,
+ int iterations,
+ int overhead
+);
+
+/*********************************************************************/
+/*********************************************************************/
+/************** TEST SUPPORT **************/
+/*********************************************************************/
+/*********************************************************************/
+
+void locked_print_initialize(void);
+
+int locked_printf(const char *fmt, ...);
+
+int locked_vprintf(const char *fmt, va_list ap);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/testsuites/include/tmacros.h b/testsuites/include/tmacros.h
new file mode 100644
index 0000000..fe17bc0
--- /dev/null
+++ b/testsuites/include/tmacros.h
@@ -0,0 +1,283 @@
+/**
+ * @file
+ *
+ * This include file contains macros which are useful in the RTEMS
+ * test suites.
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2014.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef __TMACROS_h
+#define __TMACROS_h
+
+#include <inttypes.h>
+#include <rtems/inttypes.h>
+#include <bsp.h> /* includes <rtems.h> */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rtems/error.h>
+#include <rtems/test-info.h>
+#include <rtems/score/threaddispatch.h>
+
+#include <buffer_test_io.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FOREVER 1 /* infinite loop */
+
+#ifdef CONFIGURE_INIT
+#define TEST_EXTERN
+#else
+#define TEST_EXTERN extern
+#endif
+
+/*
+ * Check that that the dispatch disable level is proper for the
+ * mode/state of the test. Normally it should be 0 when in task space.
+ */
+#define check_dispatch_disable_level( _expect ) \
+ do { \
+ if ( (_expect) != -1 \
+ && (((!_Thread_Dispatch_is_enabled()) == false && (_expect) != 0) \
+ || ((!_Thread_Dispatch_is_enabled()) && (_expect) == 0)) \
+ ) { \
+ printf( \
+ "\n_Thread_Dispatch_disable_level is (%i)" \
+ " not %d detected at %s:%d\n", \
+ !_Thread_Dispatch_is_enabled(), (_expect), __FILE__, __LINE__ ); \
+ rtems_test_exit( 1 ); \
+ } \
+ } while ( 0 )
+
+/*
+ * Check that that the allocator mutex is not owned by the executing thread.
+ */
+#include <rtems/score/apimutex.h>
+#define check_if_allocator_mutex_is_not_owned() \
+ do { \
+ if ( _RTEMS_Allocator_is_owner() ) { \
+ printf( \
+ "\nRTEMS Allocator Mutex is owned by executing thread " \
+ "and should not be.\n" \
+ "Detected at %s:%d\n", \
+ __FILE__, \
+ __LINE__ \
+ ); \
+ rtems_test_exit( 1 ); \
+ } \
+ } while ( 0 )
+
+/*
+ * These macros properly report errors within the Classic API
+ */
+#define directive_failed( _dirstat, _failmsg ) \
+ fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
+
+#define directive_failed_with_level( _dirstat, _failmsg, _level ) \
+ fatal_directive_status_with_level( \
+ _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
+
+#define fatal_directive_status( _stat, _desired, _msg ) \
+ fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
+
+#define fatal_directive_check_status_only( _stat, _desired, _msg ) \
+ do { \
+ if ( (_stat) != (_desired) ) { \
+ printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
+ (_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
+ rtems_test_exit( _stat ); \
+ } \
+ } while ( 0 )
+
+#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
+ do { \
+ check_dispatch_disable_level( _level ); \
+ check_if_allocator_mutex_is_not_owned(); \
+ fatal_directive_check_status_only( _stat, _desired, _msg ); \
+ } while ( 0 )
+
+/*
+ * These macros properly report errors from the POSIX API
+ */
+
+#define posix_service_failed( _dirstat, _failmsg ) \
+ fatal_posix_service_status( _dirstat, 0, _failmsg )
+
+#define posix_service_failed_with_level( _dirstat, _failmsg, _level ) \
+ fatal_posix_service_status_with_level( _dirstat, 0, _failmsg, _level )
+
+#define fatal_posix_service_status_errno( _stat, _desired, _msg ) \
+ if ( (_stat != -1) && (errno) != (_desired) ) { \
+ long statx = _stat; \
+ check_dispatch_disable_level( 0 ); \
+ check_if_allocator_mutex_is_not_owned(); \
+ printf( "\n%s FAILED -- expected (%d - %s) got (%ld %d - %s)\n", \
+ (_msg), _desired, strerror(_desired), \
+ statx, errno, strerror(errno) ); \
+ rtems_test_exit( _stat ); \
+ }
+
+#define fatal_posix_service_status( _stat, _desired, _msg ) \
+ fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
+
+#define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
+ do { \
+ check_dispatch_disable_level( _level ); \
+ check_if_allocator_mutex_is_not_owned(); \
+ if ( (_stat) != (_desired) ) { \
+ printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
+ (_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
+ printf( "\n FAILED -- errno (%d - %s)\n", \
+ errno, strerror(errno) ); \
+ rtems_test_exit( _stat ); \
+ } \
+ } while ( 0 )
+
+/*
+ * This macro evaluates the semaphore id returned.
+ */
+#define fatal_posix_sem( _ptr, _msg ) \
+ if ( (_ptr != SEM_FAILED) ) { \
+ check_dispatch_disable_level( 0 ); \
+ printf( "\n%s FAILED -- expected (-1) got (%p - %d/%s)\n", \
+ (_msg), _ptr, errno, strerror(errno) ); \
+ rtems_test_exit( -1 ); \
+ }
+
+/*
+ * This macro evaluates the message queue id returned.
+ */
+#define fatal_posix_mqd( _ptr, _msg ) \
+ if ( (_ptr != (mqd_t) -1) ) { \
+ check_dispatch_disable_level( 0 ); \
+ printf( "\n%s FAILED -- expected (-1) got (%" PRId32 " - %d/%s)\n", \
+ (_msg), _ptr, errno, strerror(errno) ); \
+ rtems_test_exit( -1 ); \
+ }
+
+/*
+ * Generic integer version of the error reporting
+ */
+
+#define int_service_failed( _dirstat, _failmsg ) \
+ fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
+
+#define int_service_failed_with_level( _dirstat, _failmsg, _level ) \
+ fatal_int_service_status_with_level( \
+ _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
+
+#define fatal_int_service_status( _stat, _desired, _msg ) \
+ fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
+
+#define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
+ do { \
+ check_dispatch_disable_level( _level ); \
+ if ( (_stat) != (_desired) ) { \
+ printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
+ (_msg), (_desired), (_stat) ); \
+ rtems_test_exit( _stat ); \
+ } \
+ } while ( 0 )
+
+
+/*
+ * Print the time
+ */
+
+#define sprint_time(_str, _s1, _tb, _s2) \
+ do { \
+ sprintf( (_str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \
+ _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
+ (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
+ } while ( 0 )
+
+#define print_time(_s1, _tb, _s2) \
+ do { \
+ printf( "%s%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 " %02" PRIu32 "/%02" PRIu32 "/%04" PRIu32 "%s", \
+ _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
+ (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
+ } while ( 0 )
+
+#define put_dot( _c ) \
+ do { \
+ putchar( _c ); \
+ } while ( 0 )
+
+#define new_line puts( "" )
+
+#define puts_nocr printf
+
+#define put_name( name, crlf ) \
+{ int c0, c1, c2, c3; \
+ c0 = (name >> 24) & 0xff; \
+ c1 = (name >> 16) & 0xff; \
+ c2 = (name >> 8) & 0xff; \
+ c3 = name & 0xff; \
+ putchar( (isprint(c0)) ? c0 : '*' ); \
+ if ( c1 ) putchar( (isprint(c1)) ? c1 : '*' ); \
+ if ( c2 ) putchar( (isprint(c2)) ? c2 : '*' ); \
+ if ( c3 ) putchar( (isprint(c3)) ? c3 : '*' ); \
+ if ( crlf ) \
+ putchar( '\n' ); \
+}
+
+#ifndef build_time
+#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
+ { (TB)->year = YR; \
+ (TB)->month = MON; \
+ (TB)->day = DAY; \
+ (TB)->hour = HR; \
+ (TB)->minute = MIN; \
+ (TB)->second = SEC; \
+ (TB)->ticks = TK; }
+#endif
+
+#define task_number( tid ) \
+ ( rtems_object_id_get_index( tid ) - \
+ rtems_configuration_get_rtems_api_configuration()-> \
+ number_of_initialization_tasks )
+
+#define rtems_test_assert(__exp) \
+ do { \
+ if (!(__exp)) { \
+ printf( "%s: %d %s\n", __FILE__, __LINE__, #__exp ); \
+ rtems_test_exit(0); \
+ } \
+ } while (0)
+
+/**
+ * This assists in clearly disabling warnings on GCC in certain very
+ * specific cases.
+ *
+ * + -Wnon-null - If a method is declared as never having a NULL first
+ * parameter. We need to explicitly disable this compiler warning to make
+ * the code warning free.
+ */
+#ifdef __GNUC__
+ #define COMPILER_DIAGNOSTIC_SETTINGS_PUSH _Pragma("GCC diagnostic push")
+ #define COMPILER_DIAGNOSTIC_SETTINGS_POP _Pragma("GCC diagnostic pop")
+ #define COMPILER_DIAGNOSTIC_SETTINGS_DISABLE_NONNULL \
+ _Pragma("GCC diagnostic ignored \"-Wnonnull\"")
+#else
+ #define COMPILER_DIAGNOSTIC_SETTINGS_PUSH
+ #define COMPILER_DIAGNOSTIC_SETTINGS_POP
+ #define COMPILER_DIAGNOSTIC_SETTINGS_DISABLE_NONNULL
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/testsuites/include/tmtests_empty_function.h b/testsuites/include/tmtests_empty_function.h
new file mode 100644
index 0000000..a47df61
--- /dev/null
+++ b/testsuites/include/tmtests_empty_function.h
@@ -0,0 +1,23 @@
+/*
+ * Prototypes for RTEMS tmtests_empty_function.c.
+ *
+ * COPYRIGHT (c) 2011, Ralf Corsépius, Ulm/Germany.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _TMTESTS_EMPTY_FUNCTION_H
+#define _TMTESTS_EMPTY_FUNCTION_H
+
+#include <rtems/rtems/status.h>
+
+extern rtems_status_code benchmark_timer_empty_function( void );
+
+extern void benchmark_timer_empty_operation(
+ int iteration,
+ void *argument
+);
+
+#endif /* _TMTESTS_EMPTY_FUNCTION_H */