Skip to content

Commit

Permalink
Update tests to compute expected values
Browse files Browse the repository at this point in the history
Add openssl dependency for tests in tests/CMakeLists.txt

Update tests to compute the expected value and compare it
against the one generated by hardware. This involves tests
for the following commands:

DeriveKey, GenDig, HMAC, MAC, SHA

Remove tests under scripts/ as they are now obsolete.

Signed-off-by: Michalis Pappas <mpappas@fastmail.fm>
  • Loading branch information
michpappas authored and jbech-linaro committed May 7, 2018
1 parent 32a88d1 commit 5a401f0
Show file tree
Hide file tree
Showing 6 changed files with 395 additions and 133 deletions.
17 changes: 8 additions & 9 deletions atsha204a/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ MESSAGE(STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER})
add_compile_options(-Wall -Werror)
include_directories(include)

set(SRC src/cmd.c
src/crc.c
src/debug.c
src/io.c
src/main.c
src/i2c_linux.c
src/packet.c
src/personalize.c)
set(SRC ${CMAKE_SOURCE_DIR}/src/cmd.c
${CMAKE_SOURCE_DIR}/src/crc.c
${CMAKE_SOURCE_DIR}/src/debug.c
${CMAKE_SOURCE_DIR}/src/io.c
${CMAKE_SOURCE_DIR}/src/i2c_linux.c
${CMAKE_SOURCE_DIR}/src/packet.c
${CMAKE_SOURCE_DIR}/src/personalize.c)

#add_definitions(-DPERSONALIZE)
set(I2C_DEVICE "/dev/i2c-0")

#add_definitions(-DEXT_DEBUG_INFO)
add_definitions(-DCMAKE_BUILD_TYPE=Debug)

add_executable(${PROJECT_NAME} ${SRC})
add_executable(${PROJECT_NAME} ${SRC} ${CMAKE_SOURCE_DIR}/src/main.c)

target_compile_definitions(${PROJECT_NAME}
PRIVATE -DI2C_DEVICE="${I2C_DEVICE}"
Expand Down
2 changes: 2 additions & 0 deletions atsha204a/include/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ enum {
*/
uint8_t SLOT_CONFIG_ADDR(uint8_t slotnbr);

#define SLOT_DATA_SIZE 32

#define SLOT_ADDR(id) (8 * id)
#define SLOT_CONFIG_OFFSET(slotnbr) (slotnbr % 2 ? 2 : 0)
#define SLOT_CONFIG_SIZE 0x2
Expand Down
45 changes: 0 additions & 45 deletions atsha204a/scripts/atsha204a_test_mac.py

This file was deleted.

11 changes: 0 additions & 11 deletions atsha204a/scripts/atsha204a_test_sha.py

This file was deleted.

5 changes: 3 additions & 2 deletions atsha204a/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ project(s96-204_tests C)

cmake_minimum_required(VERSION 3.0.2)

file(GLOB SRC ${CMAKE_SOURCE_DIR}/src/*.c)
list(REMOVE_ITEM SRC ${CMAKE_SOURCE_DIR}/src/main.c)
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})

add_executable(${PROJECT_NAME} EXCLUDE_FROM_ALL ${SRC} tests.c)

target_compile_definitions(${PROJECT_NAME}
PRIVATE -DI2C_DEVICE="${I2C_DEVICE}"
PRIVATE -DDEBUG
)
target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES})
Loading

0 comments on commit 5a401f0

Please sign in to comment.