Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Florian Fischer
emper-echo-server
Commits
4cee2d13
Commit
4cee2d13
authored
Dec 04, 2020
by
Florian Fischer
Browse files
remove useless test dir
parent
fb4cab0b
Pipeline
#53309
failed with stages
in 37 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
meson.build
View file @
4cee2d13
...
...
@@ -23,4 +23,3 @@ emper_dep = emper_proj.get_variable('emper_dep')
dependencies = [emper_dep]
subdir('src')
subdir('test')
test/.clang-tidy
deleted
100644 → 0
View file @
fb4cab0b
Checks: -readability-magic-numbers,-clang-analyzer-unix.Malloc,-clang-analyzer-optin.portability.UnixAPI
test/concurrent_test.c
deleted
100644 → 0
View file @
fb4cab0b
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright © 2020 Florian Fischer
#include
<pthread.h>
#include
<stdio.h>
// for asprintf
#include
<stdlib.h>
// for size_t, free, malloc
#include
<string.h>
// for strlen, strcmp, strcpy, strncmp
#include
<sys/sysinfo.h>
#include
"hash_table.h"
#include
"hash_table_entry.h"
// for ht_value_t, value
#define HT_DEFAULT_SIZE 10
static
char
*
new_str
(
const
char
*
s
)
{
char
*
as
;
asprintf
(
&
as
,
"%s"
,
s
);
return
as
;
}
static
ht_value_t
new_str_value
(
const
char
*
d
)
{
size_t
data_len
=
strlen
(
d
)
+
1
;
ht_value_t
v
=
ht_value_new
(
data_len
,
0
);
if
(
v
)
{
memcpy
(
v
->
data
,
d
,
data_len
);
}
return
v
;
}
static
void
insert
(
ht_t
*
ht
,
const
char
*
key
,
const
char
*
d
)
{
char
*
k
=
new_str
(
key
);
ht_value_t
v
=
new_str_value
(
d
);
bool
res
=
ht_set
(
ht
,
k
,
v
);
if
(
!
res
)
{
printf
(
"can't set key %s to value %s
\n
"
,
key
,
v
->
data
);
exit
(
1
);
}
}
static
void
find_present
(
ht_t
*
ht
,
const
char
*
key
,
const
char
*
expected_value
,
const
char
*
msg
)
{
ht_value_t
v
;
bool
found
=
ht_get
(
ht
,
key
,
&
v
);
if
(
!
found
)
{
printf
(
"Can't find value for %s %s
\n
"
,
msg
,
key
);
exit
(
1
);
}
if
(
!
(
strcmp
(
v
->
data
,
expected_value
)
==
0
))
{
printf
(
"expected value '%s' does not match '%s'
\n
"
,
expected_value
,
v
->
data
);
exit
(
1
);
}
}
static
void
find_absent
(
ht_t
*
ht
,
const
char
*
key
,
const
char
*
msg
)
{
ht_value_t
v
;
bool
found
=
ht_get
(
ht
,
key
,
&
v
);
if
(
found
)
{
printf
(
"found value for %s %s with value v: %s
\n
"
,
msg
,
key
,
v
->
data
);
exit
(
1
);
}
}
ht_t
*
ht
;
const
size_t
iterations
=
10000
;
void
*
thread_func
(
void
*
arg
)
{
char
*
key_char
=
(
char
*
)
arg
;
char
key_str
[
2
];
key_str
[
0
]
=
*
key_char
;
key_str
[
1
]
=
0
;
// terminate string
for
(
size_t
i
=
0
;
i
<
iterations
;
++
i
)
{
insert
(
ht
,
key_str
,
key_str
);
find_present
(
ht
,
key_str
,
key_str
,
"concurrently inserted key"
);
bool
removed
=
ht_remove
(
ht
,
key_str
);
if
(
!
removed
)
{
printf
(
"just inserted key %s not present for removal
\n
"
,
key_str
);
exit
(
1
);
}
find_absent
(
ht
,
key_str
,
"inserted and removed key"
);
}
return
NULL
;
}
int
main
()
{
ht
=
ht_new
(
HT_DEFAULT_SIZE
);
int
nprocs
=
get_nprocs
();
int
double_capacity
=
ht_get_capacity
(
ht
)
*
2
;
int
nthreads
=
nprocs
>
double_capacity
?
nprocs
:
double_capacity
;
pthread_t
*
threads
=
malloc
(
sizeof
(
pthread_t
)
*
nthreads
);
if
(
!
threads
)
{
perror
(
"malloc failed"
);
exit
(
1
);
}
char
*
key_chars
=
malloc
(
sizeof
(
char
)
*
nthreads
);
if
(
!
key_chars
)
{
perror
(
"malloc failed"
);
exit
(
1
);
}
for
(
int
i
=
0
;
i
<
nthreads
;
++
i
)
{
key_chars
[
i
]
=
'A'
+
i
;
pthread_create
(
&
threads
[
i
],
NULL
,
thread_func
,
&
key_chars
[
i
]);
}
for
(
int
i
=
0
;
i
<
nthreads
;
++
i
)
{
pthread_join
(
threads
[
i
],
NULL
);
}
ht_free
(
ht
);
}
test/meson.build
deleted
100644 → 0
View file @
fb4cab0b
tests = {
# 'simple_test.c':
# {
# 'description': 'Simple test',
# 'smoke_test': true,
# },
}
# Meson integration for GTest and GMock
# See https://mesonbuild.com/Dependencies.html#gtest-and-gmock
gtest_dep = dependency('gtest', main: true)
#subdir('fixtures')
foreach source, test_dict : tests
# TODO: Use meson fs (filesystem) module once meson >= 0.53 is in
# buster-backports, instead of split('.')[0]
# test_name = fs.replace_suffix(source, '')
# The test_name is the name of the source file without the file suffix.
test_name = source.split('.')[0]
test_dep = [dependency('threads')]
if test_dict.get('gtest', false)
test_dep += gtest_dep
endif
test_exe = executable(test_name, source,
include_directories: [include_dir],
#link_with: beehive_hash_table_lib,
dependencies: test_dep,
)
if test_dict.get('smoke_test', false)
test_suite = 'smoke'
else
test_suite = 'all'
endif
test(test_dict.get('description', ''),
test_exe,
is_parallel: test_dict.get('is_parallel', true),
suite: test_suite,
timeout: 60
)
endforeach
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment