Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
f494b20b
Commit
f494b20b
authored
Apr 09, 2018
by
Jens Korinth
Browse files
Update the remaining platform tests
parent
d5c11aa9
Changes
3
Hide whitespace changes
Inline
Side-by-side
platform/tests/CMakeLists.txt
View file @
f494b20b
...
...
@@ -25,10 +25,10 @@ set_target_properties(platform-alloc PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_
target_link_libraries
(
platform-alloc m platform atomic pthread
)
add_executable
(
platform-slots platform_slots.c
${
TAPASCO_PLATFORM_LIB
}
)
target_link_libraries
(
platform-slots
pthread
platform
)
target_link_libraries
(
platform-slots
m
platform
atomic pthread
)
add_executable
(
iplatform iplatform.c
)
target_link_libraries
(
iplatform
pthread
platform ncurses
${
TAPASCO_PLATFORM_LIB
}
)
target_link_libraries
(
iplatform
m
platform
atomic pthread
ncurses
${
TAPASCO_PLATFORM_LIB
}
)
set_target_properties
(
platform-stress-alloc platform-stress-ioctl platform-slots iplatform PROPERTIES COMPILE_FLAGS
${
TAPASCO_CFLAGS
}
)
set_target_properties
(
platform-stress-alloc platform-stress-ioctl platform-slots iplatform PROPERTIES LINKER_FLAGS
${
TAPASCO_LDFLAGS
}
)
...
...
platform/tests/iplatform.c
View file @
f494b20b
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
// Copyright (C) 2014
-2018
Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (T
PC
).
// This file is part of Tapasco (T
aPaSCo
).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -17,8 +17,7 @@
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
//
/**
* @file stress-ioctl.c
* @brief
* @file iplatform.c
* @author J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
**/
#include
<fcntl.h>
...
...
@@ -36,6 +35,8 @@
#include
<sched.h>
#include
<platform.h>
static
platform_ctx_t
*
ctx
=
NULL
;
static
platform_devctx_t
*
devctx
=
NULL
;
static
long
thrdcnt
=
0
;
static
volatile
int
stop
=
0
;
static
volatile
int
finish
=
0
;
...
...
@@ -65,15 +66,15 @@ static inline void copy_check(size_t const *lp)
random_fill
(
data1
,
sz
);
if
(
platform_alloc
(
sz
,
&
addr
,
PLATFORM_ALLOC_FLAGS_NONE
)
==
PLATFORM_SUCCESS
&&
platform_write_mem
(
addr
,
sz
,
data1
,
PLATFORM_MEM_FLAGS_NONE
)
if
(
platform_alloc
(
devctx
,
sz
,
&
addr
,
PLATFORM_ALLOC_FLAGS_NONE
)
==
PLATFORM_SUCCESS
&&
platform_write_mem
(
devctx
,
addr
,
sz
,
data1
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
__atomic_fetch_add
(
&
alloced_bytes
,
sz
,
__ATOMIC_SEQ_CST
);
__atomic_fetch_add
(
&
copyto_bytes
,
sz
,
__ATOMIC_SEQ_CST
);
if
(
platform_read_mem
(
addr
,
sz
,
data2
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
if
(
platform_read_mem
(
devctx
,
addr
,
sz
,
data2
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
__atomic_fetch_add
(
&
copyfrom_bytes
,
sz
,
__ATOMIC_SEQ_CST
);
}
else
__atomic_fetch_add
(
&
errors
,
1
,
__ATOMIC_SEQ_CST
);
if
(
platform_dealloc
(
addr
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
if
(
platform_dealloc
(
devctx
,
addr
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
__atomic_fetch_add
(
&
freed_bytes
,
sz
,
__ATOMIC_SEQ_CST
);
}
else
__atomic_fetch_add
(
&
errors
,
1
,
__ATOMIC_SEQ_CST
);
}
else
__atomic_fetch_add
(
&
errors
,
1
,
__ATOMIC_SEQ_CST
);
...
...
@@ -89,9 +90,9 @@ static inline void alloc_free(size_t const *lp)
{
size_t
sz
=
lp
?
*
lp
:
rand
()
%
(
1
<<
20
)
&
~
0x3
;
platform_mem_addr_t
addr
;
if
(
platform_alloc
(
sz
,
&
addr
,
PLATFORM_ALLOC_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
if
(
platform_alloc
(
devctx
,
sz
,
&
addr
,
PLATFORM_ALLOC_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
{
__atomic_fetch_add
(
&
alloced_bytes
,
sz
,
__ATOMIC_SEQ_CST
);
if
(
platform_dealloc
(
addr
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
if
(
platform_dealloc
(
devctx
,
addr
,
PLATFORM_MEM_FLAGS_NONE
)
==
PLATFORM_SUCCESS
)
__atomic_fetch_add
(
&
freed_bytes
,
sz
,
__ATOMIC_SEQ_CST
);
else
__atomic_fetch_add
(
&
errors
,
1
,
__ATOMIC_SEQ_CST
);
...
...
@@ -102,13 +103,13 @@ static inline void platform_write_ctl_speed(void)
{
const
uint32_t
x
=
0xe5ae1337
;
uint32_t
d
=
42
;
if
(
platform_write_ctl
(
platform_address_get_slot_base
(
0
,
0
)
+
0x20
,
if
(
platform_write_ctl
(
devctx
,
platform_address_get_slot_base
(
devctx
,
0
,
0
)
+
0x20
,
4
,
&
x
,
PLATFORM_CTL_FLAGS_NONE
)
!=
PLATFORM_SUCCESS
)
{
__atomic_fetch_add
(
&
errors
,
1
,
__ATOMIC_SEQ_CST
);
}
else
{
__atomic_fetch_add
(
&
copyto_bytes
,
4
,
__ATOMIC_SEQ_CST
);
}
if
(
platform_read_ctl
(
platform_address_get_slot_base
(
0
,
0
)
+
0x20
,
if
(
platform_read_ctl
(
devctx
,
platform_address_get_slot_base
(
devctx
,
0
,
0
)
+
0x20
,
4
,
&
d
,
PLATFORM_CTL_FLAGS_NONE
)
!=
PLATFORM_SUCCESS
||
d
!=
x
)
{
__atomic_fetch_add
(
&
errors
,
1
,
__ATOMIC_SEQ_CST
);
}
else
{
...
...
@@ -160,17 +161,22 @@ static int runtest(long const which)
getmaxyx
(
stdscr
,
rows
,
cols
);
platform_res_t
res
=
platform_init
();
platform_res_t
res
=
platform_init
(
&
ctx
);
if
(
res
!=
PLATFORM_SUCCESS
)
{
exit_ncurses
();
fprintf
(
stderr
,
"Platform init failed: %s"
,
platform_strerror
(
errno
));
fprintf
(
stderr
,
"Platform init failed: %s
\n
"
,
platform_strerror
(
res
));
exit
(
EXIT_FAILURE
);
}
if
((
res
=
platform_create_device
(
ctx
,
0
,
PLATFORM_EXCLUSIVE_ACCESS
,
&
devctx
))
!=
PLATFORM_SUCCESS
)
{
exit_ncurses
();
fprintf
(
stderr
,
"Platform create device failed: %s
\n
"
,
platform_strerror
(
res
));
platform_deinit
(
ctx
);
exit
(
EXIT_FAILURE
);
}
clear
();
mvprintw
(
rows
/
2
,
(
cols
-
strlen
(
stre
))
/
2
,
stre
);
clock_gettime
(
CLOCK_MONOTONIC
,
&
tv_begin
);
for
(
long
t
=
0
;
t
<
thrdcnt
;
++
t
)
...
...
@@ -222,7 +228,8 @@ static int runtest(long const which)
for
(
long
t
=
0
;
t
<
thrdcnt
;
++
t
)
pthread_join
(
threads
[
t
],
NULL
);
platform_deinit
();
platform_destroy_device
(
ctx
,
0
);
platform_deinit
(
ctx
);
return
errors
+
terrors
;
}
...
...
platform/tests/platform_slots.c
View file @
f494b20b
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
// Copyright (C) 2014
-2018
Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (T
PC
).
// This file is part of Tapasco (T
aPaSCo
).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
...
...
@@ -31,11 +31,11 @@
#include
<platform.h>
#include
"common.h"
#define
SLOTS_BASE (platform_address_get_slot_base(0,0))
#define
COUNTER_ID 14
#define SLOTS_OFFSET (0x00010000)
#define PLATFORM_SLOTS 128
static
platform_ctx_t
*
ctx
;
static
platform_devctx_t
*
devctx
;
static
platform_info_t
info
;
struct
cfg_t
{
long
all_slots
,
slot_id
,
delay
,
iterations
,
mt
;
...
...
@@ -43,26 +43,29 @@ struct cfg_t {
static
int
call_slot
(
struct
cfg_t
const
*
cfg
,
short
unsigned
const
slot_id
)
{
printf
(
"Calling
you a
slot #%u ...
\n
"
,
slot_id
);
printf
(
"Calling slot #%u ...
\n
"
,
slot_id
);
uint32_t
cd_loops
=
cfg
->
delay
<=
clock_period
()
?
1
:
(
cfg
->
delay
/
clock_period
()
-
2
)
>>
1
;
const
uint32_t
addr
=
SLOTS_BASE
+
slot_id
*
SLOTS_OFFSET
;
const
uint32_t
addr
=
info
.
base
.
arch
[
slot_id
]
;
const
uint32_t
fire
=
1
;
uint32_t
retval
=
0
;
for
(
long
i
=
0
;
i
<
cfg
->
iterations
;
++
i
)
{
if
(
!
check
(
platform_write_ctl
(
addr
+
0x4
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
if
(
info
.
composition
.
kernel
[
slot_id
]
!=
COUNTER_ID
)
return
0
;
if
(
!
check
(
platform_write_ctl
(
devctx
,
addr
+
0x4
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
return
1
;
if
(
!
check
(
platform_write_ctl
(
devctx
,
addr
+
0x8
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
return
1
;
if
(
!
check
(
platform_write_ctl
(
addr
+
0x
8
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
if
(
!
check
(
platform_write_ctl
(
devctx
,
addr
+
0x
20
,
sizeof
(
cd_loops
),
&
cd_loops
,
PLATFORM_CTL_FLAGS_NONE
)
))
return
1
;
if
(
!
check
(
platform_write_ctl
(
addr
+
0x20
,
sizeof
(
cd_loops
),
&
cd_loops
,
PLATFORM_CTL_FLAGS_NONE
)
))
if
(
!
check
(
platform_write_ctl
(
devctx
,
addr
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
return
1
;
if
(
!
check
(
platform_w
r
it
e_ctl_and_wait
(
addr
,
sizeof
(
fire
),
&
fire
,
slot_id
,
PLATFORM_CTL_FLAGS_NONE
)
))
if
(
!
check
(
platform_w
a
it
_for_slot
(
devctx
,
slot_id
)
))
return
1
;
if
(
!
check
(
platform_write_ctl
(
addr
+
0xc
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
if
(
!
check
(
platform_write_ctl
(
devctx
,
addr
+
0xc
,
sizeof
(
fire
),
&
fire
,
PLATFORM_CTL_FLAGS_NONE
)
))
return
1
;
if
(
!
check
(
platform_read_ctl
(
addr
+
0x10
,
sizeof
(
retval
),
&
retval
,
PLATFORM_CTL_FLAGS_NONE
)
))
if
(
!
check
(
platform_read_ctl
(
devctx
,
addr
+
0x10
,
sizeof
(
retval
),
&
retval
,
PLATFORM_CTL_FLAGS_NONE
)
))
return
1
;
if
(
retval
!
=
cd_loops
)
{
fprintf
(
stderr
,
"ERROR: returned value = %u, expected: %u
\n
"
,
retval
,
cd_loops
);
if
(
retval
<
=
cd_loops
)
{
fprintf
(
stderr
,
"ERROR: returned value = %u, expected:
>=
%u
\n
"
,
retval
,
cd_loops
);
return
1
;
}
}
...
...
@@ -120,34 +123,38 @@ int main(int argc, char **argv)
printf
(
"Starting: all_slots = %ld, slot_id = %ld, delay = %ld, iterations = %ld
\n
"
,
cfg
.
all_slots
,
cfg
.
slot_id
,
cfg
.
delay
,
cfg
.
iterations
);
if
((
res
=
platform_init
())
!=
PLATFORM_SUCCESS
)
{
fprintf
(
stderr
,
"Failed to initialize Platform API: %s
\n
"
,
platform_strerror
(
res
));
if
((
res
=
platform_init
(
&
ctx
))
!=
PLATFORM_SUCCESS
)
{
fprintf
(
stderr
,
"Failed to initialize Platform API: %s
\n
"
,
platform_strerror
(
res
));
exit
(
EXIT_FAILURE
);
}
else
if
((
res
=
platform_create_device
(
ctx
,
0
,
PLATFORM_EXCLUSIVE_ACCESS
,
&
devctx
))
!=
PLATFORM_SUCCESS
)
{
fprintf
(
stderr
,
"Failed to create Platform device: %s
\n
"
,
platform_strerror
(
res
));
platform_deinit
(
ctx
);
exit
(
EXIT_FAILURE
);
}
platform_info
(
devctx
,
&
info
);
if
(
cfg
.
all_slots
)
{
if
(
cfg
.
mt
)
{
pthread_t
t
[
PLATFORM_SLOTS
];
long
ret
[
PLATFORM_SLOTS
];
struct
call_t
c
[
PLATFORM_SLOTS
];
for
(
int
i
=
0
;
i
<
PLATFORM_SLOTS
;
++
i
)
{
pthread_t
t
[
PLATFORM_
NUM_
SLOTS
];
long
ret
[
PLATFORM_
NUM_
SLOTS
];
struct
call_t
c
[
PLATFORM_
NUM_
SLOTS
];
for
(
int
i
=
0
;
i
<
PLATFORM_
NUM_
SLOTS
;
++
i
)
{
c
[
i
].
cfg
=
&
cfg
;
c
[
i
].
slot_id
=
i
;
pthread_create
(
&
t
[
i
],
NULL
,
run_call_slot
,
&
c
[
i
]);
}
for
(
int
i
=
0
;
i
<
PLATFORM_SLOTS
;
++
i
)
for
(
int
i
=
0
;
i
<
PLATFORM_
NUM_
SLOTS
;
++
i
)
pthread_join
(
t
[
i
],
(
void
*
)
&
ret
[
i
]);
for
(
int
i
=
0
;
i
<
PLATFORM_SLOTS
;
++
i
)
for
(
int
i
=
0
;
i
<
PLATFORM_
NUM_
SLOTS
;
++
i
)
errs
+=
ret
[
i
];
}
else
{
// TODO number of slots can be queried where? TPC?
for
(
unsigned
short
i
=
0
;
i
<
PLATFORM_SLOTS
;
++
i
)
{
for
(
unsigned
short
i
=
0
;
i
<
PLATFORM_NUM_SLOTS
;
++
i
)
{
errs
+=
call_slot
(
&
cfg
,
i
);
}
}
}
else
{
errs
=
call_slot
(
&
cfg
,
cfg
.
slot_id
);
}
platform_deinit
();
platform_destroy_device
(
ctx
,
0
);
platform_deinit
(
ctx
);
return
errs
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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