iPXE
Macros | Functions | Variables
memset_test.c File Reference

memset() self-tests More...

#include <string.h>
#include <ipxe/test.h>

Go to the source code of this file.

Macros

#define MEMSET_TEST_CONSTANT(len)
 Perform a constant-length memset() test. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void memset_zero_0 (void *dest)
 
void memset_zero_1 (void *dest)
 
void memset_zero_2 (void *dest)
 
void memset_zero_3 (void *dest)
 
void memset_zero_4 (void *dest)
 
void memset_zero_5 (void *dest)
 
void memset_zero_6 (void *dest)
 
void memset_zero_7 (void *dest)
 
void memset_zero_8 (void *dest)
 
void memset_zero_9 (void *dest)
 
void memset_zero_10 (void *dest)
 
void memset_zero_11 (void *dest)
 
void memset_zero_12 (void *dest)
 
void memset_zero_13 (void *dest)
 
void memset_zero_14 (void *dest)
 
void memset_zero_15 (void *dest)
 
void memset_zero_16 (void *dest)
 
void memset_zero_17 (void *dest)
 
void memset_zero_18 (void *dest)
 
void memset_zero_19 (void *dest)
 
void memset_zero_20 (void *dest)
 
void memset_zero_21 (void *dest)
 
void memset_zero_22 (void *dest)
 
void memset_zero_23 (void *dest)
 
void memset_zero_24 (void *dest)
 
void memset_zero_25 (void *dest)
 
void memset_zero_26 (void *dest)
 
void memset_zero_27 (void *dest)
 
void memset_zero_28 (void *dest)
 
void memset_zero_29 (void *dest)
 
void memset_zero_30 (void *dest)
 
void memset_zero_31 (void *dest)
 
void * memset_var (void *dest, unsigned int fill, size_t len)
 Force a call to the variable-length implementation of memset() More...
 
static void memset_test_exec (void)
 Perform memset() self-tests. More...
 

Variables

struct self_test memset_test __self_test
 memset() self-test More...
 

Detailed Description

memset() self-tests

Definition in file memset_test.c.

Macro Definition Documentation

◆ MEMSET_TEST_CONSTANT

#define MEMSET_TEST_CONSTANT (   len)
Value:
do { \
uint8_t dest_const[ 1 + len + 1 ]; \
uint8_t dest_var[ 1 + len + 1 ]; \
static uint8_t zero[len]; \
unsigned int i; \
\
for ( i = 0 ; i < sizeof ( dest_const ) ; i++ ) \
dest_const[i] = 0xaa; \
memset ( ( dest_const + 1 ), 0, len ); \
ok ( dest_const[0] == 0xaa ); \
ok ( dest_const[ sizeof ( dest_const ) - 1 ] == 0xaa ); \
ok ( memcmp ( ( dest_const + 1 ), zero, len ) == 0 ); \
\
for ( i = 0 ; i < sizeof ( dest_var ) ; i++ ) \
dest_var[i] = 0xbb; \
memset_var ( ( dest_var + 1 ), 0, len ); \
ok ( dest_var[0] == 0xbb ); \
ok ( dest_var[ sizeof ( dest_var ) - 1 ] == 0xbb ); \
ok ( memcmp ( ( dest_var + 1 ), zero, len ) == 0 ); \
} while ( 0 )
uint32_t zero
Must be zero.
Definition: ntlm.h:24
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:98

Perform a constant-length memset() test.

Parameters
lenLength of data

Definition at line 91 of file memset_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ memset_zero_0()

void memset_zero_0 ( void *  dest)

Definition at line 40 of file memset_test.c.

40 { memset ( dest, 0, 0 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_1()

void memset_zero_1 ( void *  dest)

Definition at line 41 of file memset_test.c.

41 { memset ( dest, 0, 1 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_2()

void memset_zero_2 ( void *  dest)

Definition at line 42 of file memset_test.c.

42 { memset ( dest, 0, 2 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_3()

void memset_zero_3 ( void *  dest)

Definition at line 43 of file memset_test.c.

43 { memset ( dest, 0, 3 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_4()

void memset_zero_4 ( void *  dest)

Definition at line 44 of file memset_test.c.

44 { memset ( dest, 0, 4 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_5()

void memset_zero_5 ( void *  dest)

Definition at line 45 of file memset_test.c.

45 { memset ( dest, 0, 5 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_6()

void memset_zero_6 ( void *  dest)

Definition at line 46 of file memset_test.c.

46 { memset ( dest, 0, 6 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_7()

void memset_zero_7 ( void *  dest)

Definition at line 47 of file memset_test.c.

47 { memset ( dest, 0, 7 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_8()

void memset_zero_8 ( void *  dest)

Definition at line 48 of file memset_test.c.

48 { memset ( dest, 0, 8 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_9()

void memset_zero_9 ( void *  dest)

Definition at line 49 of file memset_test.c.

49 { memset ( dest, 0, 9 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_10()

void memset_zero_10 ( void *  dest)

Definition at line 50 of file memset_test.c.

50 { memset ( dest, 0, 10 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_11()

void memset_zero_11 ( void *  dest)

Definition at line 51 of file memset_test.c.

51 { memset ( dest, 0, 11 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_12()

void memset_zero_12 ( void *  dest)

Definition at line 52 of file memset_test.c.

52 { memset ( dest, 0, 12 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_13()

void memset_zero_13 ( void *  dest)

Definition at line 53 of file memset_test.c.

53 { memset ( dest, 0, 13 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_14()

void memset_zero_14 ( void *  dest)

Definition at line 54 of file memset_test.c.

54 { memset ( dest, 0, 14 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_15()

void memset_zero_15 ( void *  dest)

Definition at line 55 of file memset_test.c.

55 { memset ( dest, 0, 15 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_16()

void memset_zero_16 ( void *  dest)

Definition at line 56 of file memset_test.c.

56 { memset ( dest, 0, 16 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_17()

void memset_zero_17 ( void *  dest)

Definition at line 57 of file memset_test.c.

57 { memset ( dest, 0, 17 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_18()

void memset_zero_18 ( void *  dest)

Definition at line 58 of file memset_test.c.

58 { memset ( dest, 0, 18 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_19()

void memset_zero_19 ( void *  dest)

Definition at line 59 of file memset_test.c.

59 { memset ( dest, 0, 19 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_20()

void memset_zero_20 ( void *  dest)

Definition at line 60 of file memset_test.c.

60 { memset ( dest, 0, 20 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_21()

void memset_zero_21 ( void *  dest)

Definition at line 61 of file memset_test.c.

61 { memset ( dest, 0, 21 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_22()

void memset_zero_22 ( void *  dest)

Definition at line 62 of file memset_test.c.

62 { memset ( dest, 0, 22 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_23()

void memset_zero_23 ( void *  dest)

Definition at line 63 of file memset_test.c.

63 { memset ( dest, 0, 23 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_24()

void memset_zero_24 ( void *  dest)

Definition at line 64 of file memset_test.c.

64 { memset ( dest, 0, 24 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_25()

void memset_zero_25 ( void *  dest)

Definition at line 65 of file memset_test.c.

65 { memset ( dest, 0, 25 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_26()

void memset_zero_26 ( void *  dest)

Definition at line 66 of file memset_test.c.

66 { memset ( dest, 0, 26 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_27()

void memset_zero_27 ( void *  dest)

Definition at line 67 of file memset_test.c.

67 { memset ( dest, 0, 27 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_28()

void memset_zero_28 ( void *  dest)

Definition at line 68 of file memset_test.c.

68 { memset ( dest, 0, 28 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_29()

void memset_zero_29 ( void *  dest)

Definition at line 69 of file memset_test.c.

69 { memset ( dest, 0, 29 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_30()

void memset_zero_30 ( void *  dest)

Definition at line 70 of file memset_test.c.

70 { memset ( dest, 0, 30 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_zero_31()

void memset_zero_31 ( void *  dest)

Definition at line 71 of file memset_test.c.

71 { memset ( dest, 0, 31 ); }
static void * dest
Definition: strings.h:176
void * memset(void *dest, int character, size_t len) __nonnull

References dest, and memset().

◆ memset_var()

void* memset_var ( void *  dest,
unsigned int  fill,
size_t  len 
)

Force a call to the variable-length implementation of memset()

Parameters
destDestination address
fillFill pattern
lenLength of data
Return values
destDestination address

Definition at line 81 of file memset_test.c.

82  {
83  return memset ( dest, fill, len );
84 }
static void * dest
Definition: strings.h:176
uint32_t len
Length.
Definition: ena.h:14
uint8_t fill
Length pair.
Definition: deflate.h:12
void * memset(void *dest, int character, size_t len) __nonnull

References dest, fill, len, and memset().

◆ memset_test_exec()

static void memset_test_exec ( void  )
static

Perform memset() self-tests.

Definition at line 116 of file memset_test.c.

116  {
117 
118  /* Constant-length tests */
119  MEMSET_TEST_CONSTANT ( 0 );
120  MEMSET_TEST_CONSTANT ( 1 );
121  MEMSET_TEST_CONSTANT ( 2 );
122  MEMSET_TEST_CONSTANT ( 3 );
123  MEMSET_TEST_CONSTANT ( 4 );
124  MEMSET_TEST_CONSTANT ( 5 );
125  MEMSET_TEST_CONSTANT ( 6 );
126  MEMSET_TEST_CONSTANT ( 7 );
127  MEMSET_TEST_CONSTANT ( 8 );
128  MEMSET_TEST_CONSTANT ( 9 );
129  MEMSET_TEST_CONSTANT ( 10 );
130  MEMSET_TEST_CONSTANT ( 11 );
131  MEMSET_TEST_CONSTANT ( 12 );
132  MEMSET_TEST_CONSTANT ( 13 );
133  MEMSET_TEST_CONSTANT ( 14 );
134  MEMSET_TEST_CONSTANT ( 15 );
135  MEMSET_TEST_CONSTANT ( 16 );
136  MEMSET_TEST_CONSTANT ( 17 );
137  MEMSET_TEST_CONSTANT ( 18 );
138  MEMSET_TEST_CONSTANT ( 19 );
139  MEMSET_TEST_CONSTANT ( 20 );
140  MEMSET_TEST_CONSTANT ( 21 );
141  MEMSET_TEST_CONSTANT ( 22 );
142  MEMSET_TEST_CONSTANT ( 23 );
143  MEMSET_TEST_CONSTANT ( 24 );
144  MEMSET_TEST_CONSTANT ( 25 );
145  MEMSET_TEST_CONSTANT ( 26 );
146  MEMSET_TEST_CONSTANT ( 27 );
147  MEMSET_TEST_CONSTANT ( 28 );
148  MEMSET_TEST_CONSTANT ( 29 );
149  MEMSET_TEST_CONSTANT ( 30 );
150  MEMSET_TEST_CONSTANT ( 31 );
151 }
#define MEMSET_TEST_CONSTANT(len)
Perform a constant-length memset() test.
Definition: memset_test.c:91

References MEMSET_TEST_CONSTANT.

Variable Documentation

◆ __self_test

struct self_test memset_test __self_test
Initial value:
= {
.name = "memset",
}
static void memset_test_exec(void)
Perform memset() self-tests.
Definition: memset_test.c:116

memset() self-test

Definition at line 154 of file memset_test.c.