Reworks workflows into script (#661)

* Reworks some workflows to run a script instead

Advantages are:
- Only one set of tests needs maintenance.
- Local results match workflows, no surprises.
- Reduced reliance on GitHub actions.

Fixes #50, #168, #169, #171, #507

* Adds macos to the test matrix
This commit is contained in:
kaczmarczyck
2023-11-08 17:24:15 +01:00
committed by GitHub
parent 3a5adfc5af
commit e5ba9db644
30 changed files with 130 additions and 745 deletions

View File

@@ -205,7 +205,6 @@ impl ecdsa::Signature for SoftwareEcdsaSignature {
Some(SoftwareEcdsaSignature { signature })
}
#[cfg(feature = "std")]
fn to_slice(&self, bytes: &mut [u8; EC_SIGNATURE_SIZE]) {
bytes.copy_from_slice(&self.signature.to_bytes());
}

View File

@@ -161,10 +161,10 @@ impl PrivateKey {
let wrapped_bytes = extract_byte_string(array.pop().unwrap())?;
let key_bytes = aes256_cbc_decrypt::<E>(wrap_key, &wrapped_bytes, true)?;
match SignatureAlgorithm::try_from(array.pop().unwrap())? {
SignatureAlgorithm::Es256 => PrivateKey::new_ecdsa_from_bytes(&*key_bytes)
SignatureAlgorithm::Es256 => PrivateKey::new_ecdsa_from_bytes(&key_bytes)
.ok_or(Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR),
#[cfg(feature = "ed25519")]
SignatureAlgorithm::Eddsa => PrivateKey::new_ed25519_from_bytes(&*key_bytes)
SignatureAlgorithm::Eddsa => PrivateKey::new_ed25519_from_bytes(&key_bytes)
.ok_or(Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR),
_ => Err(Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR),
}

View File

@@ -13,8 +13,7 @@
// limitations under the License.
use fuzz_store::{fuzz, StatKey, Stats};
use std::io::Write;
use std::io::{stdout, Read};
use std::io::{stdout, Read, Write};
use std::path::Path;
fn usage(program: &str) {

View File

@@ -490,7 +490,7 @@ impl StoreDriverOn {
/// Checks that the given entries are wiped from the storage.
fn check_deleted(&self, deleted: &[StoreHandle]) -> Result<(), StoreInvariant> {
for handle in deleted {
let value = self.store.inspect_value(&handle);
let value = self.store.inspect_value(handle);
if !value.iter().all(|&x| x == 0x00) {
return Err(StoreInvariant::NotWiped {
key: handle.get_key(),

View File

@@ -187,7 +187,7 @@ impl Format {
word_size == WORD_SIZE
&& page_size % word_size == 0
&& (MIN_PAGE_SIZE * word_size <= page_size && page_size <= MAX_PAGE_SIZE)
&& (MIN_NUM_PAGES <= num_pages && num_pages <= MAX_PAGE_INDEX + 1)
&& (MIN_NUM_PAGES..=MAX_PAGE_INDEX + 1).contains(&num_pages)
&& max_word_writes >= 2
&& max_page_erases <= MAX_ERASE_CYCLE
}

View File

@@ -146,7 +146,7 @@ pub fn delete(store: &mut Store<impl Storage>, keys: &impl Keys) -> StoreResult<
/// The handles are truncated to the keys that are present.
fn get_handles(store: &Store<impl Storage>, keys: &impl Keys) -> StoreResult<Vec<StoreHandle>> {
let keys_len = keys.len();
let mut handles: Vec<Option<StoreHandle>> = vec![None; keys_len as usize];
let mut handles: Vec<Option<StoreHandle>> = vec![None; keys_len];
for handle in store.iter()? {
let handle = handle?;
let pos = match keys.pos(handle.get_key()) {

View File

@@ -148,7 +148,7 @@ impl<S: Storage> Linear<S> {
value = &value[len..];
index.byte += len;
// Write the unaligned end if needed.
if value.len() > 0 {
if !value.is_empty() {
let mut word = self.storage.read_slice(index, word_size)?.into_owned();
word[..value.len()].copy_from_slice(value);
self.storage.write_slice(index, &word)?;

View File

@@ -19,12 +19,10 @@ use crate::format::{
Word, WordState,
};
#[cfg(feature = "std")]
pub use crate::model::{StoreModel, StoreOperation};
use crate::{usize_to_nat, Nat, Storage, StorageError, StorageIndex};
pub use crate::model::StoreOperation;
#[cfg(feature = "std")]
pub use crate::{
BufferStorage, StoreDriver, StoreDriverOff, StoreDriverOn, StoreInterruption, StoreInvariant,
};
pub use crate::BufferStorage;
use crate::{usize_to_nat, Nat, Storage, StorageError, StorageIndex};
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::vec::Vec;
@@ -245,7 +243,7 @@ impl<S: Storage> Store<S> {
}
/// Iterates over the entries.
pub fn iter<'a>(&'a self) -> StoreResult<StoreIter<'a>> {
pub fn iter(&self) -> StoreResult<StoreIter<'_>> {
let head = or_invalid(self.head)?;
Ok(Box::new(or_invalid(self.entries.as_ref())?.iter().map(
move |&offset| {
@@ -794,7 +792,7 @@ impl<S: Storage> Store<S> {
/// Continues a transaction after it has been written.
fn transaction_apply(&mut self, sorted_keys: &[Nat], marker: Position) -> StoreResult<()> {
self.delete_keys(&sorted_keys, marker)?;
self.delete_keys(sorted_keys, marker)?;
self.set_padding(marker)?;
let end = or_invalid(self.head)? + self.format.window_size();
let mut pos = marker + 1;