blob: f2abb2f6b0208b7502e718a9aface8e93a1aa2fa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST
void
librecrypt_set_user_data(LIBRECRYPT_CONTEXT *ctx, void *user)
{
ctx->user_data = user;
}
#else
extern LIBRECRYPT_CONTEXT *volatile ctx;
LIBRECRYPT_CONTEXT *volatile ctx;
int
main(void)
{
char *user = &(char){0};
SET_UP_ALARM();
INIT_RESOURCE_TEST();
ctx = librecrypt_create_context();
assert(ctx != NULL);
EXPECT(librecrypt_get_user_data(ctx) == NULL);
EXPECT(librecrypt_get_user_data(ctx) == NULL);
librecrypt_set_user_data(ctx, user);
EXPECT(librecrypt_get_user_data(ctx) == user);
EXPECT(librecrypt_get_user_data(ctx) == user);
librecrypt_set_user_data(ctx, user);
librecrypt_set_user_data(ctx, NULL);
EXPECT(librecrypt_get_user_data(ctx) == NULL);
EXPECT(librecrypt_get_user_data(ctx) == NULL);
librecrypt_set_user_data(ctx, NULL);
librecrypt_free_context(ctx);
STOP_RESOURCE_TEST();
return 0;
}
#endif
|