blob: a3191ccd00f228111b19f6f1d990f9df1d530bb1 [file] [log] [blame]
Jose Marinhoa1dfeda2019-02-27 16:46:03 +00001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17extern "C" {
18#include "vmapi/hf/spci.h"
19}
20
21#include <gmock/gmock.h>
22
23namespace
24{
25using ::testing::Eq;
26
27/**
28 * Ensure that spci_message_init is correctly setting the expected fields in the
29 * SPCI common message header.
30 */
31TEST(spci, spci_message_init)
32{
33 spci_message header;
34 spci_message compare_header = {
35 .flags = SPCI_MESSAGE_IMPDEF_MASK,
36 .length = 1,
37 .target_vm_id = 2,
38 .source_vm_id = 3,
39 };
40
41 memset(&header, 0xff, sizeof(header));
42 spci_message_init(&header, 1, 2, 3);
43
44 EXPECT_THAT(memcmp(&header, &compare_header, sizeof(header)), 0);
45}
46} /* namespace */