-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Improved test infrastructure
- Make clear what is host code and what is cluster code
- Loading branch information
Showing
8 changed files
with
128 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,30 @@ | |
# Moritz Scherer <[email protected]> | ||
# Philip Wiese <[email protected]> | ||
|
||
file(GLOB_RECURSE TEST_SRCS | ||
"src/test.c" | ||
) | ||
set(TEST_NAME test_host_returnZero) | ||
|
||
add_chimera_test( | ||
test_host_returnZero | ||
${TEST_SRCS} | ||
######## HOST Code ############################################################# | ||
file(GLOB_RECURSE TEST_HOST_SRCS | ||
"src_host/*.c" | ||
) | ||
|
||
target_compile_options(test_host_returnZero | ||
add_library(${TEST_NAME}_host OBJECT ${TEST_HOST_SRCS}) | ||
# target_include_directories(${TEST_NAME}_host PUBLIC include) | ||
|
||
# WIESEP: Set the correct ISA and ABI for the host | ||
target_compile_options(${TEST_NAME}_host | ||
PRIVATE | ||
-O2 | ||
-march=${ISA_HOST} | ||
-mabi=${ABI_HOST} | ||
) | ||
target_link_libraries(${TEST_NAME}_host PUBLIC chimera-sdk) | ||
|
||
|
||
target_link_libraries(test_host_returnZero PUBLIC chimera-sdk) | ||
######## TEST Executable ####################################################### | ||
add_chimera_test( | ||
${TEST_NAME} | ||
) | ||
|
||
# WIESEP: Link the host to the test executable (chimera-sdk is already linked) | ||
target_link_libraries(${TEST_NAME} PUBLIC ${TEST_NAME}_host) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,47 @@ | |
# Moritz Scherer <[email protected]> | ||
# Philip Wiese <[email protected]> | ||
|
||
file(GLOB_RECURSE TEST_SRCS | ||
"src/test.c" | ||
set(TEST_NAME test_snitchCluster_simpleOffload) | ||
|
||
######## HOST Code ############################################################# | ||
file(GLOB_RECURSE TEST_HOST_SRCS | ||
"src_host/*.c" | ||
) | ||
|
||
add_chimera_test( | ||
test_snitchCluster_simpleOffload | ||
${TEST_SRCS} | ||
add_library(${TEST_NAME}_host OBJECT ${TEST_HOST_SRCS}) | ||
target_include_directories(${TEST_NAME}_host PUBLIC include) | ||
|
||
# WIESEP: Set the correct ISA and ABI for the host | ||
target_compile_options(${TEST_NAME}_host | ||
PRIVATE | ||
-O2 | ||
-march=${ISA_HOST} | ||
-mabi=${ABI_HOST} | ||
) | ||
target_link_libraries(${TEST_NAME}_host PUBLIC chimera-sdk) | ||
|
||
target_compile_options(test_snitchCluster_simpleOffload | ||
######## CLUSTER Code ########################################################## | ||
file(GLOB_RECURSE TEST_SNITCH_SRCS | ||
"src_cluster/*.c" | ||
) | ||
|
||
add_library(${TEST_NAME}_cluster OBJECT ${TEST_SNITCH_SRCS}) | ||
target_include_directories(${TEST_NAME}_cluster PUBLIC include) | ||
|
||
# WIESEP: Set the correct ISA and ABI for the cluster | ||
target_compile_options(${TEST_NAME}_cluster | ||
PRIVATE | ||
-O2 | ||
-march=${ISA_CLUSTER_SNITCH} | ||
-mabi=${ABI_CLUSTER_SNITCH} | ||
) | ||
target_link_libraries(${TEST_NAME}_cluster PUBLIC chimera-sdk) | ||
|
||
######## TEST Executable ####################################################### | ||
add_chimera_test( | ||
${TEST_NAME} | ||
) | ||
|
||
target_link_libraries(test_snitchCluster_simpleOffload PUBLIC chimera-sdk) | ||
# WIESEP: Link the host and cluster code to the test executable (chimera-sdk is already linked) | ||
target_link_libraries(${TEST_NAME} PUBLIC ${TEST_NAME}_host) | ||
target_link_libraries(${TEST_NAME} PUBLIC ${TEST_NAME}_cluster) |
16 changes: 16 additions & 0 deletions
16
tests/generic/snitchCluster/simpleOffload/include/test_cluster.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Philip Wiese <[email protected]> | ||
|
||
#ifndef _TEST_CLUSTER_INCLUDE_GUARD_ | ||
#define _TEST_CLUSTER_INCLUDE_GUARD_ | ||
|
||
#include <stdint.h> | ||
|
||
void clusterInterruptHandler(); | ||
|
||
int32_t testReturn(void *args); | ||
|
||
#endif //_TEST_CLUSTER_INCLUDE_GUARD_ |
16 changes: 16 additions & 0 deletions
16
tests/generic/snitchCluster/simpleOffload/include/test_host.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Philip Wiese <[email protected]> | ||
|
||
#ifndef _TEST_HOST_INCLUDE_GUARD_ | ||
#define _TEST_HOST_INCLUDE_GUARD_ | ||
|
||
#define TESTVAL 0x050CCE55 | ||
|
||
typedef struct { | ||
int value; | ||
} offloadArgs_t; | ||
|
||
#endif //_TEST_HOST_INCLUDE_GUARD_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,18 @@ | |
// | ||
// Moritz Scherer <[email protected]> | ||
|
||
#include "soc.h" | ||
#include "driver.h" | ||
|
||
#include <stddef.h> | ||
#include "test_cluster.h" | ||
#include "test_host.h" | ||
|
||
#define TESTVAL 0x050CCE55 | ||
#define STACK_ADDRESS (CLUSTER_4_BASE + 0x20000 - 8) | ||
#include "soc.h" | ||
|
||
static uint32_t *clintPointer = (uint32_t *)CLINT_CTRL_BASE; | ||
|
||
// WIESEP: Stack, thread and global pointer might not yet be set up! | ||
/** | ||
* @brief Interrupt handler for the cluster, which clears the interrupt flag for the current hart. | ||
* | ||
* @warning Stack, thread and global pointer might not yet be set up! | ||
*/ | ||
__attribute__((naked)) void clusterInterruptHandler() { | ||
asm volatile( | ||
// Load global pointer | ||
|
@@ -42,12 +43,11 @@ __attribute__((naked)) void clusterInterruptHandler() { | |
); | ||
} | ||
|
||
typedef struct { | ||
int value; | ||
} offloadArgs_t; | ||
|
||
static offloadArgs_t offloadArgs = {.value = 0xdeadbeef}; | ||
|
||
/** | ||
* @brief Main function of the cluster test. | ||
* | ||
* @return int Return 0 if the test was successful, -1 otherwise. | ||
*/ | ||
int32_t testReturn(void *args) { | ||
// Cast to the correct struct | ||
offloadArgs_t *argsStruct = (offloadArgs_t *)args; | ||
|
@@ -58,12 +58,4 @@ int32_t testReturn(void *args) { | |
} | ||
|
||
return TESTVAL; | ||
} | ||
|
||
int main() { | ||
setup_snitchCluster_interruptHandler(clusterInterruptHandler); | ||
offload_snitchCluster_core(testReturn, &offloadArgs, (void *)(STACK_ADDRESS), 4, 0); | ||
uint32_t retVal = wait_snitchCluster_return(4); | ||
|
||
return (retVal != (TESTVAL | 0x000000001)); | ||
} |
23 changes: 23 additions & 0 deletions
23
tests/generic/snitchCluster/simpleOffload/src_host/test_host.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2024 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Moritz Scherer <[email protected]> | ||
|
||
#include "test_cluster.h" | ||
#include "test_host.h" | ||
|
||
#include "soc.h" | ||
#include "driver.h" | ||
|
||
#define STACK_ADDRESS (CLUSTER_4_BASE + 0x20000 - 8) | ||
|
||
static offloadArgs_t offloadArgs = {.value = 0xdeadbeef}; | ||
|
||
int main() { | ||
setup_snitchCluster_interruptHandler(clusterInterruptHandler); | ||
offload_snitchCluster_core(testReturn, &offloadArgs, (void *)(STACK_ADDRESS), 4, 0); | ||
uint32_t retVal = wait_snitchCluster_return(4); | ||
|
||
return (retVal != (TESTVAL | 0x000000001)); | ||
} |