Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the spdm_device_validator_sample to SPDM-Responder-Validator #156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions .github/workflows/build_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ jobs:
echo "requester.log size is `stat -c%s "$filename"`"
exit 1
fi
- name: Responder_validator_Test
run: |
cd build/bin
./spdm_responder_emu &
./spdm_device_validator_sample

- name: Test_RECORD_TRANSCRIPT_DATA_consistent
# open LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT flag
# mkdir build1 folder, gen spdm_requester_emu.exe and spdm_responder_emu.exe
Expand Down Expand Up @@ -224,11 +220,7 @@ jobs:
echo "requester.log size is `stat -c%s "$filename"`"
exit 1
fi
- name: Responder_validator_Test
run: |
cd build/bin
./spdm_responder_emu &
./spdm_device_validator_sample

- name: Test_RECORD_TRANSCRIPT_DATA_consistent
# open LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT flag
# mkdir build1 folder, gen spdm_requester_emu.exe and spdm_responder_emu.exe
Expand Down Expand Up @@ -335,11 +327,6 @@ jobs:
cd build/bin
./spdm_responder_emu &
./spdm_requester_emu
- name: Responder_validator_Test
run: |
cd build/bin
./spdm_responder_emu &
./spdm_device_validator_sample

VS2019_openssl_build:
runs-on: windows-latest
Expand Down Expand Up @@ -367,8 +354,3 @@ jobs:
cd build/bin
./spdm_responder_emu &
./spdm_requester_emu
- name: Responder_validator_Test
run: |
cd build/bin
./spdm_responder_emu &
./spdm_device_validator_sample
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "libspdm"]
path = libspdm
url = https://github.com/DMTF/libspdm
[submodule "SPDM-Responder-Validator"]
path = SPDM-Responder-Validator
url = https://github.com/DMTF/SPDM-Responder-Validator
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ if(NOT GCOV)
endif()

SET(LIBSPDM_DIR ${PROJECT_SOURCE_DIR}/libspdm)
SET(SPDM_RESPONDER_VALIDATOR_DIR ${PROJECT_SOURCE_DIR}/SPDM-Responder-Validator)
SET(COMMON_TEST_FRAMEWORK_DIR ${PROJECT_SOURCE_DIR}/SPDM-Responder-Validator/common_test_framework)

#
Expand Down Expand Up @@ -548,11 +547,9 @@ endif()
ADD_SUBDIRECTORY(library/cxl_ide_km_requester_lib)
ADD_SUBDIRECTORY(library/cxl_ide_km_responder_lib)
ADD_SUBDIRECTORY(library/cxl_ide_km_device_lib_sample)
ADD_SUBDIRECTORY(library/common_test_utility_lib)
ADD_SUBDIRECTORY(library/spdm_responder_conformance_test_lib)
ADD_SUBDIRECTORY(spdm_emu/spdm_requester_emu)
ADD_SUBDIRECTORY(spdm_emu/spdm_responder_emu)

ADD_SUBDIRECTORY(${COMMON_TEST_FRAMEWORK_DIR}/library/common_test_utility_lib out/common_test_utility_lib.out)
ADD_SUBDIRECTORY(${SPDM_RESPONDER_VALIDATOR_DIR}/library/spdm_responder_conformance_test_lib out/spdm_responder_conformance_test_lib.out)
ADD_SUBDIRECTORY(spdm_emu/spdm_device_validator_sample)

ADD_SUBDIRECTORY(spdm_emu/spdm_device_attester_sample)
1 change: 0 additions & 1 deletion SPDM-Responder-Validator
Submodule SPDM-Responder-Validator deleted from 61debb
175 changes: 175 additions & 0 deletions include/library/common_test_utility_lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/**
* Copyright Notice:
* Copyright 2021 DMTF, Componolit. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

#ifndef __COMMON_TEST_UTILITY_LIB_H__
#define __COMMON_TEST_UTILITY_LIB_H__

#include "library/spdm_common_lib.h"

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>

typedef uint32_t common_test_group_id;
typedef uint32_t common_test_case_id;
typedef uint32_t common_test_assertion_id;

/* This can be used as "end of list" indicator. */
#define COMMON_TEST_ID_END 0
/* This can be used as "test skip" indicator. */
#define COMMON_TEST_ID_SKIP 0xFFFFFFFF

typedef enum {
COMMON_TEST_RESULT_NOT_TESTED,
COMMON_TEST_RESULT_PASS,
COMMON_TEST_RESULT_FAIL,
} common_test_result_t;

typedef void (*common_test_case_func_t) (void *test_context);

/**
* @return true setup successfully
* @return false setup fail
**/
typedef bool (*common_test_case_setup_func_t) (void *test_context);
typedef void (*common_test_case_teardown_func_t) (void *test_context);

/**
* @return true setup successfully
* @return false setup fail
**/
typedef bool (*common_test_group_setup_func_t) (void *test_context);
typedef void (*common_test_group_teardown_func_t) (void *test_context);

/**
*
+------------+
| test suite |
+------------+
| +------------+
+----------->| test group |
| +------------+
| | +------------+
| +----------->| test case |
| | +------------+
| |
| | +------------+
| +----------->| test case |
| +------------+
| +------------+
+----------->| test group |
+------------+
|
**/

typedef struct {
uint32_t case_id;
char *case_name;
common_test_case_func_t case_func;
common_test_case_setup_func_t case_setup_func;
common_test_case_teardown_func_t case_teardown_func;
} common_test_case_t;

typedef struct {
uint32_t group_id;
char *group_name;
common_test_case_t *test_cases;
common_test_group_setup_func_t group_setup_func;
common_test_group_teardown_func_t group_teardown_func;
} common_test_group_t;

typedef struct {
char *name;
common_test_group_t *test_groups;
} common_test_suite_t;

/**
*
+-------------------+
| test suite config |
+-------------------+
| +-------------------+
+----------->| test group config |
| +-------------------+
| | +-------------------+
| +----------->| test case config |
| | +-------------------+
| |
| | +-------------------+
| +----------->| test case config |
| +-------------------+
| +-------------------+
+----------->| test group config |
+-------------------+
|
| rules:
| 1) NULL == RUN
| 2) not-found == SKIP
| 3) SKIP + RUN == RUN + SKIP == SKIP
|
+==========================================+
| suite | group | case | ACTION |
+==========================================+
| NULL | - | - | RUN |
+------------------------------------------+
| exist | NULL | - | RUN |
+------------------------------------------+
| exist | not-found | - | SKIP |
+------------------------------------------+
| exist | found:SKIP | - | SKIP |
+------------------------------------------+
| exist | found:RUN | NULL | RUN |
+------------------------------------------+
| exist | found:RUN | not-found | SKIP |
+------------------------------------------+
| exist | found:RUN | found:SKIP | SKIP |
+------------------------------------------+
| exist | found:RUN | found:RUN | RUN |
+==========================================+
|
**/

typedef enum {
COMMON_TEST_ACTION_RUN,
COMMON_TEST_ACTION_SKIP,
} common_test_action_t;

typedef struct {
uint32_t case_id;
common_test_action_t action;
} common_test_case_config_t;

typedef struct {
uint32_t group_id;
common_test_action_t action;
common_test_case_config_t *test_case_configs;
} common_test_group_config_t;

typedef struct {
char *config_name;
common_test_group_config_t *test_group_configs;
} common_test_suite_config_t;

void common_test_run_test_suite (
void *test_context,
const common_test_suite_t *test_suite,
const common_test_suite_config_t *test_suite_config);

void common_test_record_test_assertion (
common_test_group_id group_id,
common_test_case_id case_id,
common_test_assertion_id assertion_id,
common_test_result_t test_result,
const char *message_format,
...);

void common_test_record_test_message(const char *message_format, ...);

#endif
132 changes: 132 additions & 0 deletions include/library/spdm_responder_conformance_test_lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/**
* Copyright Notice:
* Copyright 2021 DMTF, Componolit. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
**/

#ifndef __SPDM_RESPONDER_CONFORMANCE_TEST_LIB_H__
#define __SPDM_RESPONDER_CONFORMANCE_TEST_LIB_H__

#include "library/spdm_common_lib.h"
#include "library/common_test_utility_lib.h"

void spdm_responder_conformance_test (void *spdm_context,
const common_test_suite_config_t *test_config);

/* below definition should be aligned with test case description in doc dir */

#define SPDM_RESPONDER_TEST_GROUP_VERSION 1
#define SPDM_RESPONDER_TEST_CASE_VERSION_SUCCESS_10 1
#define SPDM_RESPONDER_TEST_CASE_VERSION_INVALID_REQUEST 2

#define SPDM_RESPONDER_TEST_GROUP_CAPABILITIES 2
#define SPDM_RESPONDER_TEST_CASE_CAPABILITIES_SUCCESS_10 1
#define SPDM_RESPONDER_TEST_CASE_CAPABILITIES_VERSION_MISMATCH 2
#define SPDM_RESPONDER_TEST_CASE_CAPABILITIES_SUCCESS_11 3
#define SPDM_RESPONDER_TEST_CASE_CAPABILITIES_INVALID_REQUEST 4
#define SPDM_RESPONDER_TEST_CASE_CAPABILITIES_SUCCESS_12 5
#define SPDM_RESPONDER_TEST_CASE_CAPABILITIES_UNEXPECTED_REQUEST_NON_IDENTICAL 6

#define SPDM_RESPONDER_TEST_GROUP_ALGORITHMS 3
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_SUCCESS_10 1
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_VERSION_MISMATCH 2
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_UNEXPECTED_REQUEST 3
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_INVALID_REQUEST 4
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_SUCCESS_11 5
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_SUCCESS_12 6
#define SPDM_RESPONDER_TEST_CASE_ALGORITHMS_UNEXPECTED_REQUEST_NON_IDENTICAL 7

#define SPDM_RESPONDER_TEST_GROUP_DIGESTS 4
#define SPDM_RESPONDER_TEST_CASE_DIGESTS_SUCCESS_10 1
#define SPDM_RESPONDER_TEST_CASE_DIGESTS_VERSION_MISMATCH 2
#define SPDM_RESPONDER_TEST_CASE_DIGESTS_UNEXPECTED_REQUEST 3

#define SPDM_RESPONDER_TEST_GROUP_CERTIFICATE 5
#define SPDM_RESPONDER_TEST_CASE_CERTIFICATE_SUCCESS_10 1
#define SPDM_RESPONDER_TEST_CASE_CERTIFICATE_VERSION_MISMATCH 2
#define SPDM_RESPONDER_TEST_CASE_CERTIFICATE_UNEXPECTED_REQUEST 3
#define SPDM_RESPONDER_TEST_CASE_CERTIFICATE_INVALID_REQUEST 4
#define SPDM_RESPONDER_TEST_CASE_CERTIFICATE_SPDM_X509_CERTIFICATE 5

#define SPDM_RESPONDER_TEST_GROUP_CHALLENGE_AUTH 6
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_10_A1B1C1 1
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_10_A1B2C1 2
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_10_A1B3C1 3
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_VERSION_MISMATCH 4
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_UNEXPECTED_REQUEST 5
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_INVALID_REQUEST 6
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A1B1C1 11
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A1B2C1 12
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A1B3C1 13
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A1B4C1 14
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A2B1C1 15
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A2B2C1 16
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A2B3C1 17
#define SPDM_RESPONDER_TEST_CASE_CHALLENGE_AUTH_SUCCESS_12_A2B4C1 18

#define SPDM_RESPONDER_TEST_GROUP_MEASUREMENTS 7
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_SUCCESS_10 1
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_VERSION_MISMATCH 2
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_UNEXPECTED_REQUEST 3
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_INVALID_REQUEST 4
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_SPDM_MEASUREMENT_BLOCK 5
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_SUCCESS_11 6
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_SUCCESS_11_IN_DHE_SESSION 7
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_UNEXPECTED_REQUEST_IN_DHE_SESSION_HS 8
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_SUCCESS_12 9
#define SPDM_RESPONDER_TEST_CASE_MEASUREMENTS_SUCCESS_12_IN_DHE_SESSION 10

#define SPDM_RESPONDER_TEST_GROUP_KEY_EXCHANGE_RSP 8
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_SUCCESS_11 1
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_SUCCESS_11_HS_CLEAR 2
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_VERSION_MISMATCH 3
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_UNEXPECTED_REQUEST 4
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_UNEXPECTED_REQUEST_IN_SESSION 5
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_INVALID_REQUEST 6
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_SUCCESS_12 7
#define SPDM_RESPONDER_TEST_CASE_KEY_EXCHANGE_RSP_SUCCESS_12_HS_CLEAR 8

#define SPDM_RESPONDER_TEST_GROUP_FINISH_RSP 9
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_SUCCESS_11 \
1
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_SUCCESS_11_HS_CLEAR \
2
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_VERSION_MISMATCH \
3
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_UNEXPECTED_REQUEST \
4
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_UNEXPECTED_REQUEST_IN_SESSION \
5
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_INVALID_REQUEST \
6
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_DECRYPT_ERROR_INVALID_VERIFY_DATA \
7
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_DECRYPT_ERROR_INVALID_VERIFY_DATA_HS_CLEAR \
8
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_SUCCESS_12 \
9
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_SUCCESS_12_HS_CLEAR \
10
#define SPDM_RESPONDER_TEST_CASE_FINISH_RSP_SESSION_REQUIRED \
11

#define SPDM_RESPONDER_TEST_GROUP_HEARTBEAT_ACK 12
#define SPDM_RESPONDER_TEST_CASE_HEARTBEAT_ACK_SUCCESS_11_IN_DHE_SESSION 1
#define SPDM_RESPONDER_TEST_CASE_HEARTBEAT_ACK_VERSION_MISMATCH_IN_DHE_SESSION 2
#define SPDM_RESPONDER_TEST_CASE_HEARTBEAT_ACK_UNEXPECTED_REQUEST_IN_DHE_SESSION_HS 3
#define SPDM_RESPONDER_TEST_CASE_HEARTBEAT_ACK_SESSION_REQUIRED 4

#define SPDM_RESPONDER_TEST_GROUP_KEY_UPDATE_ACK 13
#define SPDM_RESPONDER_TEST_CASE_KEY_UPDATE_ACK_SUCCESS_11_IN_DHE_SESSION 1
#define SPDM_RESPONDER_TEST_CASE_KEY_UPDATE_ACK_VERSION_MISMATCH_IN_DHE_SESSION 2
#define SPDM_RESPONDER_TEST_CASE_KEY_UPDATE_ACK_INVALID_REQUEST_IN_DHE_SESSION 3
#define SPDM_RESPONDER_TEST_CASE_KEY_UPDATE_ACK_UNEXPECTED_REQUEST_IN_DHE_SESSION_HS 4
#define SPDM_RESPONDER_TEST_CASE_KEY_UPDATE_ACK_SESSION_REQUIRED 5

#define SPDM_RESPONDER_TEST_GROUP_END_SESSION_ACK 16
#define SPDM_RESPONDER_TEST_CASE_END_SESSION_ACK_SUCCESS_11_IN_DHE_SESSION 1
#define SPDM_RESPONDER_TEST_CASE_END_SESSION_ACK_VERSION_MISMATCH_IN_DHE_SESSION 2
#define SPDM_RESPONDER_TEST_CASE_END_SESSION_ACK_UNEXPECTED_REQUEST_IN_DHE_SESSION_HS 3
#define SPDM_RESPONDER_TEST_CASE_END_SESSION_ACK_SESSION_REQUIRED 4

#endif
Loading