5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2025-01-10 09:17:40 +03:00

tests: cleanup warnings

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-06-26 11:20:45 +02:00
parent 650070b0e6
commit 1feb04d7b8
2 changed files with 12 additions and 5 deletions

View File

@ -8,7 +8,7 @@ use pxar::decoder::sync as decoder;
use pxar::decoder::SeqRead; use pxar::decoder::SeqRead;
use pxar::encoder::sync as encoder; use pxar::encoder::sync as encoder;
use pxar::encoder::{LinkOffset, SeqWrite}; use pxar::encoder::{LinkOffset, SeqWrite};
use pxar::format::{self, mode, Device}; use pxar::format::{mode, Device};
use pxar::EntryKind as PxarEntryKind; use pxar::EntryKind as PxarEntryKind;
use pxar::Metadata; use pxar::Metadata;
@ -179,8 +179,6 @@ impl Entry {
self.no_hardlink()?; self.no_hardlink()?;
let _: () = encoder.add_socket(&self.metadata, &self.name)?; let _: () = encoder.add_socket(&self.metadata, &self.name)?;
} }
other => bail!("TODO: encode_entry for {:?}", other),
} }
Ok(()) Ok(())
} }
@ -239,6 +237,14 @@ impl Entry {
format_err!("failed to get contents for file entry: {:?}", item.path()) format_err!("failed to get contents for file entry: {:?}", item.path())
})? })?
.read_to_end(&mut data)?; .read_to_end(&mut data)?;
if data.len() as u64 != *size {
bail!(
"file {:?} was advertised to be of size {} but we read {} bytes",
item.path(),
size,
data.len(),
);
}
contents.push(make_entry()?.entry(EntryKind::File(data))); contents.push(make_entry()?.entry(EntryKind::File(data)));
} }
PxarEntryKind::Directory => { PxarEntryKind::Directory => {
@ -270,7 +276,6 @@ impl Entry {
PxarEntryKind::Socket => { PxarEntryKind::Socket => {
contents.push(make_entry()?.entry(EntryKind::Socket)); contents.push(make_entry()?.entry(EntryKind::Socket));
} }
other => todo!("decode for kind {:?}", other),
} }
} }

View File

@ -33,7 +33,9 @@ fn test1() {
let mut encoder = let mut encoder =
encoder::Encoder::from_std(&mut file, &test_fs.metadata).expect("failed to create encoder"); encoder::Encoder::from_std(&mut file, &test_fs.metadata).expect("failed to create encoder");
encode_directory(&mut encoder, &test_fs).expect("failed to encode test file system"); encode_directory(&mut encoder, &test_fs).expect("failed to encode test file system");
encoder.finish(); encoder
.finish()
.expect("failed to finish encoding the pxar archive");
assert!(!file.is_empty(), "encoder did not write any data"); assert!(!file.is_empty(), "encoder did not write any data");