[dice] Add integration tests for libdiced_open_dice[_nostd]

Test: atest libdiced_open_dice.integration_test \
libdiced_open_dice_nostd.integration_test
Bug: 267575445

Change-Id: Ie479bfc1f864d775632e3250aea04d93b2070942
This commit is contained in:
Alice Wang 2023-02-07 13:55:33 +00:00
parent 24954b4a47
commit ceb66422c6
3 changed files with 59 additions and 1 deletions

View file

@ -1,5 +1,11 @@
{
"presubmit": [
{
"name": "libdiced_open_dice.integration_test"
},
{
"name": "libdiced_open_dice_nostd.integration_test"
},
{
"name": "diced_utils_test"
},

View file

@ -46,4 +46,25 @@ rust_library {
],
}
// TODO(b/267575445): Add integration tests to check the exposed API
rust_defaults {
name: "libdiced_open_dice_test_defaults",
crate_name: "diced_open_dice_test",
srcs: ["tests/*.rs"],
test_suites: ["general-tests"],
}
rust_test {
name: "libdiced_open_dice.integration_test",
defaults: ["libdiced_open_dice_test_defaults"],
rustlibs: [
"libdiced_open_dice",
],
}
rust_test {
name: "libdiced_open_dice_nostd.integration_test",
defaults: ["libdiced_open_dice_test_defaults"],
rustlibs: [
"libdiced_open_dice_nostd",
],
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use diced_open_dice::hash;
#[test]
fn hash_succeeds() {
assert_eq!(
hash(b"hello world").expect("hash failed"),
[
0x30, 0x9e, 0xcc, 0x48, 0x9c, 0x12, 0xd6, 0xeb, 0x4c, 0xc4, 0x0f, 0x50, 0xc9, 0x02,
0xf2, 0xb4, 0xd0, 0xed, 0x77, 0xee, 0x51, 0x1a, 0x7c, 0x7a, 0x9b, 0xcd, 0x3c, 0xa8,
0x6d, 0x4c, 0xd8, 0x6f, 0x98, 0x9d, 0xd3, 0x5b, 0xc5, 0xff, 0x49, 0x96, 0x70, 0xda,
0x34, 0x25, 0x5b, 0x45, 0xb0, 0xcf, 0xd8, 0x30, 0xe8, 0x1f, 0x60, 0x5d, 0xcf, 0x7d,
0xc5, 0x54, 0x2e, 0x93, 0xae, 0x9c, 0xd7, 0x6f
]
);
}