This is basically a subset of https://github.com/mozilla/libdmg-hfsplus/pull/10, with my comments addressed.

Co-authored-by: Dave Vasilevsky <dave@vasilevsky.ca>
This commit is contained in:
Ben Hearsum 2024-09-11 15:46:43 -04:00
Родитель 5eae96a7a9
Коммит 0389a611e6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A4B76C1E8BED5BFD
8 изменённых файлов: 150 добавлений и 129 удалений

Просмотреть файл

@ -51,7 +51,7 @@ dmgs. It is separate from the HFS+ utility in order that the hfs directory
does not have dependencies on the dmg directory. does not have dependencies on the dmg directory.
The makefile in the root folder will make all utilities. The makefile in the root folder will make all utilities.
mkdir build && cd build mkdir build && cd build
cmake .. cmake ..
make # Or only make hfs / make dmg / ... make # Or only make hfs / make dmg / ...
@ -73,3 +73,10 @@ The makefile in the root folder will make all utilities.
### hdutil ### hdutil
cd hdiutil cd hdiutil
make make
TESTING
-------
* Configure in 'build': `cmake -B build`
* Install cram: `pipx install cram`
* Run tests: `cram test/*.t`

Просмотреть файл

@ -4,18 +4,20 @@ Make sure we have a fresh build:
$ cd $BUILDDIR $ cd $BUILDDIR
$ make 2> /dev/null >/dev/null $ make 2> /dev/null >/dev/null
$ cd $CRAMTMP $ cd $CRAMTMP
$ export OUTPUT=attribution_output
$ mkdir $OUTPUT
$ $BUILDDIR/dmg/dmg build $TESTDIR/attribution_reference/hdiutila.hfs testa.dmg __MOZILLA__attr-value- >/dev/null $ $BUILDDIR/dmg/dmg build $TESTDIR/attribution_reference/hdiutila.hfs $OUTPUT/testa.dmg __MOZILLA__attr-value- >/dev/null
Note the "attr-value-p" suffix below! Note the "attr-value-p" suffix below!
$ $BUILDDIR/dmg/dmg build $TESTDIR/attribution_reference/hdiutilp.hfs testb.dmg __MOZILLA__attr-value- >/dev/null $ $BUILDDIR/dmg/dmg build $TESTDIR/attribution_reference/hdiutilp.hfs $OUTPUT/testb.dmg __MOZILLA__attr-value- >/dev/null
$ xxd testa.dmg > testa.txt $ xxd $OUTPUT/testa.dmg > $OUTPUT/testa.txt
$ xxd testb.dmg > testb.txt $ xxd $OUTPUT/testb.dmg > $OUTPUT/testb.txt
$ diff --unified=3 testa.txt testb.txt $ diff --unified=3 $OUTPUT/testa.txt $OUTPUT/testb.txt
--- testa.txt* (glob) --- *testa.txt* (glob)
+++ testb.txt* (glob) +++ *testb.txt* (glob)
@@ -3349,7 +3349,7 @@ @@ -3349,7 +3349,7 @@
0000d140: 7400 7200 2d00 6b00 6500 7900 0000 1000 t.r.-.k.e.y..... 0000d140: 7400 7200 2d00 6b00 6500 7900 0000 1000 t.r.-.k.e.y.....
0000d150: 0000 0000 0000 0000 0000 175f 5f4d 4f5a ...........__MOZ 0000d150: 0000 0000 0000 0000 0000 175f 5f4d 4f5a ...........__MOZ
@ -102,7 +104,7 @@ Note the "attr-value-p" suffix below!
Check resources: Check resources:
$ $BUILDDIR/dmg/dmg res testa.dmg - | expand -t 4 $ $BUILDDIR/dmg/dmg res $OUTPUT/testa.dmg - | expand -t 4
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
@ -437,20 +439,20 @@ Check resources:
Line in the sand: Line in the sand:
$ shasum testa.dmg testb.dmg $ shasum $OUTPUT/testa.dmg $OUTPUT/testb.dmg
85f7e85acef53b63fc199e84ff801ae96b3e8c83 testa.dmg 85f7e85acef53b63fc199e84ff801ae96b3e8c83 *testa.dmg (glob)
ef6e91b330f5eacd10eb5e37603b8baa06d4a1a4 testb.dmg ef6e91b330f5eacd10eb5e37603b8baa06d4a1a4 *testb.dmg (glob)
Attribute: Attribute:
$ $BUILDDIR/dmg/dmg attribute testa.dmg testa_updated.dmg __MOZILLA__attr-value- __MOZILLA__attr-value-p >/dev/null $ $BUILDDIR/dmg/dmg attribute $OUTPUT/testa.dmg $OUTPUT/testa_updated.dmg __MOZILLA__attr-value- __MOZILLA__attr-value-p >/dev/null
Unfortunately, attributing builds does not update the cSum block, so we expect some differences here: Unfortunately, attributing builds does not update the cSum block, so we expect some differences here:
$ xxd testa_updated.dmg > testa_updated.txt $ xxd $OUTPUT/testa_updated.dmg > $OUTPUT/testa_updated.txt
$ diff --unified=3 testb.txt testa_updated.txt $ diff --unified=3 $OUTPUT/testb.txt $OUTPUT/testa_updated.txt
--- testb.txt* (glob) --- *testb.txt* (glob)
+++ testa_updated.txt* (glob) +++ *testa_updated.txt* (glob)
@@ -16831,7 +16831,7 @@ @@ -16831,7 +16831,7 @@
00041be0: 3c2f 7374 7269 6e67 3e0a 0909 0909 3c6b </string>.....<k 00041be0: 3c2f 7374 7269 6e67 3e0a 0909 0909 3c6b </string>.....<k
00041bf0: 6579 3e44 6174 613c 2f6b 6579 3e0a 0909 ey>Data</key>... 00041bf0: 6579 3e44 6174 613c 2f6b 6579 3e0a 0909 ey>Data</key>...
@ -483,19 +485,19 @@ Unfortunately, attributing builds does not update the cSum block, so we expect s
00042440: 6b2b 596e 6c30 5a58 4d38 4c32 746c 6554 k+Ynl0ZXM8L2tleT 00042440: 6b2b 596e 6c30 5a58 4d38 4c32 746c 6554 k+Ynl0ZXM8L2tleT
00042450: 344b 4354 7870 626e 526c 5a32 5679 0a09 4KCTxpbnRlZ2Vy.. 00042450: 344b 4354 7870 626e 526c 5a32 5679 0a09 4KCTxpbnRlZ2Vy..
[1] [1]
$ shasum testb.dmg testa_updated.dmg $ shasum $OUTPUT/testb.dmg $OUTPUT/testa_updated.dmg
ef6e91b330f5eacd10eb5e37603b8baa06d4a1a4 testb.dmg ef6e91b330f5eacd10eb5e37603b8baa06d4a1a4 *testb.dmg (glob)
41fadf80df5625ac458a0c1c548f37afbc41b06e testa_updated.dmg 41fadf80df5625ac458a0c1c548f37afbc41b06e *testa_updated.dmg (glob)
However, if we revert, the checksums should match again: However, if we revert, the checksums should match again:
We could also revert: We could also revert:
$ $BUILDDIR/dmg/dmg attribute testa_updated.dmg testa_reverted.dmg __MOZILLA__attr-value- __MOZILLA__attr-value-a >/dev/null $ $BUILDDIR/dmg/dmg attribute $OUTPUT/testa_updated.dmg $OUTPUT/testa_reverted.dmg __MOZILLA__attr-value- __MOZILLA__attr-value-a >/dev/null
Note -- same same: Note -- same same:
$ xxd testa_reverted.dmg > testa_reverted.txt $ xxd $OUTPUT/testa_reverted.dmg > $OUTPUT/testa_reverted.txt
$ diff --unified=3 testa.txt testa_reverted.txt $ diff --unified=3 $OUTPUT/testa.txt $OUTPUT/testa_reverted.txt
$ shasum testa.dmg testa_reverted.dmg $ shasum $OUTPUT/testa.dmg $OUTPUT/testa_reverted.dmg
85f7e85acef53b63fc199e84ff801ae96b3e8c83 testa.dmg 85f7e85acef53b63fc199e84ff801ae96b3e8c83 *testa.dmg (glob)
85f7e85acef53b63fc199e84ff801ae96b3e8c83 testa_reverted.dmg 85f7e85acef53b63fc199e84ff801ae96b3e8c83 *testa_reverted.dmg (glob)

Просмотреть файл

@ -4,36 +4,38 @@ Make sure we have a fresh build:
$ cd $BUILDDIR $ cd $BUILDDIR
$ make 2> /dev/null >/dev/null $ make 2> /dev/null >/dev/null
$ cd $CRAMTMP $ cd $CRAMTMP
$ export STAGEDIR=attribution_full_length_stagedir
$ export OUTPUT=attribution_full_length_output
Prepare content and the attribution code (997 is 1024 minus the length of the sentinel): Prepare content and the attribution code (997 is 1024 minus the length of the sentinel):
$ mkdir stagedir $ mkdir $STAGEDIR
$ echo "content-a" >> stagedir/a $ echo "content-a" >> $STAGEDIR/a
$ sentinel="__MOZILLA__attribution-code" $ sentinel="__MOZILLA__attribution-code"
$ code=$(printf "${sentinel}%*s" "997" | tr ' ' '\011') $ code=$(printf "${sentinel}%*s" "997" | tr ' ' '\011')
$ attributed_code=$(printf "${sentinel}%*s" "997" | tr ' ' '~') $ attributed_code=$(printf "${sentinel}%*s" "997" | tr ' ' '~')
Make a small HFS filesystem with a full length (1024 byte) attribution value: Make a small HFS filesystem with a full length (1024 byte) attribution value:
$ mkdir output $ mkdir $OUTPUT
$ cp $TESTDIR/empty.hfs output/full-length.hfs $ cp $TESTDIR/empty.hfs $OUTPUT/full-length.hfs
$ $BUILDDIR/hfs/hfsplus output/full-length.hfs add stagedir/a a $ $BUILDDIR/hfs/hfsplus $OUTPUT/full-length.hfs add $STAGEDIR/a a
$ $BUILDDIR/hfs/hfsplus output/full-length.hfs setattr a attr-key "$code" $ $BUILDDIR/hfs/hfsplus $OUTPUT/full-length.hfs setattr a attr-key "$code"
Echo it back, make sure it is the right length in the HFS filesystem: Echo it back, make sure it is the right length in the HFS filesystem:
$ $BUILDDIR/hfs/hfsplus output/full-length.hfs getattr a attr-key | wc -c $ $BUILDDIR/hfs/hfsplus $OUTPUT/full-length.hfs getattr a attr-key | wc -c
1024 \s*1024 (re)
Build a DMG: Build a DMG:
$ $BUILDDIR/dmg/dmg build output/full-length.hfs output/full-length.dmg "$sentinel" >/dev/null $ $BUILDDIR/dmg/dmg build $OUTPUT/full-length.hfs $OUTPUT/full-length.dmg "$sentinel" >/dev/null
Now attribute, using printable characters for the full length: Now attribute, using printable characters for the full length:
$ $BUILDDIR/dmg/dmg attribute output/full-length.dmg output/full-length-attributed.dmg "$sentinel" "$attributed_code" >/dev/null $ $BUILDDIR/dmg/dmg attribute $OUTPUT/full-length.dmg $OUTPUT/full-length-attributed.dmg "$sentinel" "$attributed_code" >/dev/null
Extract the HFS from the attributed DMG, and check to see if the code is correct: Extract the HFS from the attributed DMG, and check to see if the code is correct:
$ $BUILDDIR/dmg/dmg extract output/full-length-attributed.dmg output/full-length-attributed.hfs >/dev/null $ $BUILDDIR/dmg/dmg extract $OUTPUT/full-length-attributed.dmg $OUTPUT/full-length-attributed.hfs >/dev/null
$ $BUILDDIR/hfs/hfsplus output/full-length-attributed.hfs getattr a attr-key | grep -c "$attributed_code" $ $BUILDDIR/hfs/hfsplus $OUTPUT/full-length-attributed.hfs getattr a attr-key | grep -c "$attributed_code"
1 1

Просмотреть файл

@ -4,30 +4,32 @@ Make sure we have a fresh build:
$ cd $BUILDDIR $ cd $BUILDDIR
$ make 2> /dev/null >/dev/null $ make 2> /dev/null >/dev/null
$ cd $CRAMTMP $ cd $CRAMTMP
$ export STAGEDIR=attribution_shorter_than_sentinel_stagedir
$ export OUTPUT=attribution_shorter_than_sentinel_output
Prepare content and the attribution code: Prepare content and the attribution code:
$ mkdir stagedir $ mkdir $STAGEDIR
$ echo "content-a" >> stagedir/a $ echo "content-a" >> $STAGEDIR/a
$ sentinel="__MOZILLA__attribution-code" $ sentinel="__MOZILLA__attribution-code"
$ attribution_code="short" $ attribution_code="short"
Create the filesystem with the sentinel value in the attribute: Create the filesystem with the sentinel value in the attribute:
$ mkdir output $ mkdir $OUTPUT
$ cp $TESTDIR/empty.hfs output/short.hfs $ cp $TESTDIR/empty.hfs $OUTPUT/short.hfs
$ $BUILDDIR/hfs/hfsplus output/short.hfs add stagedir/a a $ $BUILDDIR/hfs/hfsplus $OUTPUT/short.hfs add $STAGEDIR/a a
$ $BUILDDIR/hfs/hfsplus output/short.hfs setattr a attr-key "$sentinel" $ $BUILDDIR/hfs/hfsplus $OUTPUT/short.hfs setattr a attr-key "$sentinel"
Build a DMG: Build a DMG:
$ $BUILDDIR/dmg/dmg build output/short.hfs output/short.dmg "$sentinel" >/dev/null $ $BUILDDIR/dmg/dmg build $OUTPUT/short.hfs $OUTPUT/short.dmg "$sentinel" >/dev/null
Now attribute: Now attribute:
$ $BUILDDIR/dmg/dmg attribute output/short.dmg output/short-attributed.dmg "__MOZILLA__" "$attribution_code" >/dev/null $ $BUILDDIR/dmg/dmg attribute $OUTPUT/short.dmg $OUTPUT/short-attributed.dmg "__MOZILLA__" "$attribution_code" >/dev/null
Extract the HFS from the attributed DMG, and check to see if the code is correct: Extract the HFS from the attributed DMG, and check to see if the code is correct:
$ $BUILDDIR/dmg/dmg extract output/short-attributed.dmg output/short-attributed.hfs >/dev/null $ $BUILDDIR/dmg/dmg extract $OUTPUT/short-attributed.dmg $OUTPUT/short-attributed.hfs >/dev/null
$ $BUILDDIR/hfs/hfsplus output/short-attributed.hfs getattr a attr-key | tr -d '\0' $ $BUILDDIR/hfs/hfsplus $OUTPUT/short-attributed.hfs getattr a attr-key | tr -d '\0'
short (no-eol) short (no-eol)

Просмотреть файл

@ -4,12 +4,14 @@ Make sure we have a fresh build:
$ cd $BUILDDIR $ cd $BUILDDIR
$ make 2> /dev/null >/dev/null $ make 2> /dev/null >/dev/null
$ cd $CRAMTMP $ cd $CRAMTMP
$ export STAGEDIR=hfs_xattrs_stagedir
$ export OUTPUT=hfs_xattrs_output
Prepare content: Prepare content:
$ mkdir stagedir $ mkdir $STAGEDIR
$ echo "content-a" >> stagedir/a $ echo "content-a" >> $STAGEDIR/a
$ echo "content-b" >> stagedir/b $ echo "content-b" >> $STAGEDIR/b
Extract reference HFSs and attributes. We parse the debugattrs a bit because the attribute numbers from hdiutil and hfsplus may not match: Extract reference HFSs and attributes. We parse the debugattrs a bit because the attribute numbers from hdiutil and hfsplus may not match:
@ -23,26 +25,26 @@ Extract reference HFSs and attributes. We parse the debugattrs a bit because the
Generate comparison HFSs: Generate comparison HFSs:
$ mkdir output $ mkdir $OUTPUT
$ cp $TESTDIR/empty.hfs output/stageda.hfs $ cp $TESTDIR/empty.hfs $OUTPUT/stageda.hfs
$ $BUILDDIR/hfs/hfsplus output/stageda.hfs add stagedir/a a $ $BUILDDIR/hfs/hfsplus $OUTPUT/stageda.hfs add $STAGEDIR/a a
$ $BUILDDIR/hfs/hfsplus output/stageda.hfs add stagedir/b b $ $BUILDDIR/hfs/hfsplus $OUTPUT/stageda.hfs add $STAGEDIR/b b
$ $BUILDDIR/hfs/hfsplus output/stageda.hfs setattr a 'attr-key-a' '__MOZILLA__attr-value-a__MOZILLA__' $ $BUILDDIR/hfs/hfsplus $OUTPUT/stageda.hfs setattr a 'attr-key-a' '__MOZILLA__attr-value-a__MOZILLA__'
$ $BUILDDIR/hfs/hfsplus output/stageda.hfs debugattrs verbose | grep attribute | sed -e 's/[0-9].*:/:/' > output/stageda.attrs $ $BUILDDIR/hfs/hfsplus $OUTPUT/stageda.hfs debugattrs verbose | grep attribute | sed -e 's/[0-9].*:/:/' > $OUTPUT/stageda.attrs
$ cp $TESTDIR/empty.hfs output/stagedab.hfs $ cp $TESTDIR/empty.hfs $OUTPUT/stagedab.hfs
$ $BUILDDIR/hfs/hfsplus output/stagedab.hfs add stagedir/a a $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedab.hfs add $STAGEDIR/a a
$ $BUILDDIR/hfs/hfsplus output/stagedab.hfs add stagedir/b b $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedab.hfs add $STAGEDIR/b b
$ $BUILDDIR/hfs/hfsplus output/stagedab.hfs setattr a 'attr-key-a' '__MOZILLA__attr-value-a__MOZILLA__' $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedab.hfs setattr a 'attr-key-a' '__MOZILLA__attr-value-a__MOZILLA__'
$ $BUILDDIR/hfs/hfsplus output/stagedab.hfs setattr b 'attr-key-b' '__MOZILLA__attr-value-b__MOZILLA__' $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedab.hfs setattr b 'attr-key-b' '__MOZILLA__attr-value-b__MOZILLA__'
$ $BUILDDIR/hfs/hfsplus output/stagedab.hfs debugattrs verbose | grep attribute | sed -e 's/[0-9].*:/:/' > output/stagedab.attrs $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedab.hfs debugattrs verbose | grep attribute | sed -e 's/[0-9].*:/:/' > $OUTPUT/stagedab.attrs
$ cp $TESTDIR/empty.hfs output/stagedb.hfs $ cp $TESTDIR/empty.hfs $OUTPUT/stagedb.hfs
$ $BUILDDIR/hfs/hfsplus output/stagedb.hfs add stagedir/a a $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedb.hfs add $STAGEDIR/a a
$ $BUILDDIR/hfs/hfsplus output/stagedb.hfs add stagedir/b b $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedb.hfs add $STAGEDIR/b b
$ $BUILDDIR/hfs/hfsplus output/stagedb.hfs setattr b 'attr-key-b' '__MOZILLA__attr-value-b__MOZILLA__' $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedb.hfs setattr b 'attr-key-b' '__MOZILLA__attr-value-b__MOZILLA__'
$ $BUILDDIR/hfs/hfsplus output/stagedb.hfs debugattrs verbose | grep attribute | sed -e 's/[0-9].*:/:/' > output/stagedb.attrs $ $BUILDDIR/hfs/hfsplus $OUTPUT/stagedb.hfs debugattrs verbose | grep attribute | sed -e 's/[0-9].*:/:/' > $OUTPUT/stagedb.attrs
Compare attributes in the reference images and generated images: Compare attributes in the reference images and generated images:
$ diff --unified=3 hfs_xattrs_reference/hdiutila.attrs output/stageda.attrs $ diff --unified=3 hfs_xattrs_reference/hdiutila.attrs $OUTPUT/stageda.attrs
$ diff --unified=3 hfs_xattrs_reference/hdiutilb.attrs output/stagedb.attrs $ diff --unified=3 hfs_xattrs_reference/hdiutilb.attrs $OUTPUT/stagedb.attrs
$ diff --unified=3 hfs_xattrs_reference/hdiutilab.attrs output/stagedab.attrs $ diff --unified=3 hfs_xattrs_reference/hdiutilab.attrs $OUTPUT/stagedab.attrs

Просмотреть файл

@ -5,41 +5,43 @@ time venv/bin/cram test/attribution.t --keep-tmpdir
``` ```
and then copy the reference directory like and then copy the reference directory like
``` ```
cp -R /var/folders/3s/_m9prk6n7g5cx6hhs_33q2f80000gn/T/cramtests-0uzbp0wu/reference test/reference cp -R /var/folders/3s/_m9prk6n7g5cx6hhs_33q2f80000gn/T/cramtests-0uzbp0wu/attribution_reference_reference test/attribution_reference
``` ```
to update test inputs. to update test inputs.
Make sure we have a fresh build: Make sure we have a fresh build:
$ export BUILDDIR=$TESTDIR/../build $ export BUILDDIR=$TESTDIR/../../build
$ cd $BUILDDIR $ cd $BUILDDIR
$ make &> /dev/null $ make &> /dev/null
$ cd $CRAMTMP $ cd $CRAMTMP
$ export STAGEDIR=attribution_reference_stagedir
$ export REFERENCE=attribution_reference_reference
Prepare content: Prepare content:
$ mkdir stagedir $ mkdir $STAGEDIR
$ echo "content-x" >> stagedir/x $ echo "content-x" >> $STAGEDIR/x
Create reference DMGs using macOS: Create reference DMGs using macOS:
$ mkdir reference $ mkdir $REFERENCE
$ xattr -w 'attr-key' '__MOZILLA__attr-value-a' stagedir/x $ xattr -w 'attr-key' '__MOZILLA__attr-value-a' $STAGEDIR/x
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutila.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutila.hfs
created: */reference/hdiutila.hfs.dmg (glob) created: */hdiutila.hfs.dmg (glob)
$ xattr -w 'attr-key' '__MOZILLA__attr-value-b' stagedir/x $ xattr -w 'attr-key' '__MOZILLA__attr-value-b' $STAGEDIR/x
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutilb.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutilb.hfs
created: */reference/hdiutilb.hfs.dmg (glob) created: */hdiutilb.hfs.dmg (glob)
$ xattr -w 'attr-key' '__MOZILLA__attr-value-p' stagedir/x $ xattr -w 'attr-key' '__MOZILLA__attr-value-p' $STAGEDIR/x
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutilp.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutilp.hfs
created: */reference/hdiutilp.hfs.dmg (glob) created: */hdiutilp.hfs.dmg (glob)
Extract reference HFSs: Extract reference HFSs:
$ $BUILDDIR/dmg/dmg extract reference/hdiutila.hfs.dmg reference/hdiutila.hfs > /dev/null $ $BUILDDIR/dmg/dmg extract $REFERENCE/hdiutila.hfs.dmg $REFERENCE/hdiutila.hfs > /dev/null
$ $BUILDDIR/dmg/dmg extract reference/hdiutilb.hfs.dmg reference/hdiutilb.hfs > /dev/null $ $BUILDDIR/dmg/dmg extract $REFERENCE/hdiutilb.hfs.dmg $REFERENCE/hdiutilb.hfs > /dev/null
$ $BUILDDIR/dmg/dmg extract reference/hdiutilp.hfs.dmg reference/hdiutilp.hfs > /dev/null $ $BUILDDIR/dmg/dmg extract $REFERENCE/hdiutilp.hfs.dmg $REFERENCE/hdiutilp.hfs > /dev/null
Remove the unneeded dmg: Remove the unneeded dmg:
$ rm reference/hdiutilp.hfs.dmg $ rm $REFERENCE/hdiutilp.hfs.dmg

Просмотреть файл

@ -1,21 +1,23 @@
Prepare content: Prepare content:
$ cd $CRAMTMP $ cd $CRAMTMP
$ mkdir stagedir $ export STAGEDIR=hfs_xattrs_reference_stagedir
$ echo "content-a" >> stagedir/a $ export REFERENCE=hfs_xattrs_reference_reference
$ echo "content-b" >> stagedir/b $ mkdir $STAGEDIR
$ echo "content-a" >> $STAGEDIR/a
$ echo "content-b" >> $STAGEDIR/b
Create reference DMGs using macOS: Create reference DMGs using macOS:
$ mkdir reference $ mkdir $REFERENCE
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutil.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutil.hfs
created: */reference/hdiutil.hfs.dmg (glob) created: */hdiutil.hfs.dmg (glob)
$ xattr -w 'attr-key-a' '__MOZILLA__attr-value-a' stagedir/a $ xattr -w 'attr-key-a' '__MOZILLA__attr-value-a' $STAGEDIR/a
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutila.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutila.hfs
created: */reference/hdiutila.hfs.dmg (glob) created: */hdiutila.hfs.dmg (glob)
$ xattr -w 'attr-key-b' '__MOZILLA__attr-value-b' stagedir/b $ xattr -w 'attr-key-b' '__MOZILLA__attr-value-b' $STAGEDIR/b
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutilab.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutilab.hfs
created: */reference/hdiutilab.hfs.dmg (glob) created: */hdiutilab.hfs.dmg (glob)
$ xattr -c stagedir/a $ xattr -c $STAGEDIR/a
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutilb.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutilb.hfs
created: */reference/hdiutilb.hfs.dmg (glob) created: */hdiutilb.hfs.dmg (glob)

Просмотреть файл

@ -5,47 +5,49 @@ time venv/bin/cram test/run_spanning_reference.t --keep-tmpdir
``` ```
and then copy the reference directory like and then copy the reference directory like
``` ```
cp -R /var/folders/3s/_m9prk6n7g5cx6hhs_33q2f80000gn/T/cramtests-0uzbp0wu/reference test/run_spanning_reference cp -R /var/folders/3s/_m9prk6n7g5cx6hhs_33q2f80000gn/T/cramtests-0uzbp0wu/run_spanning_reference_reference test/run_spanning_reference
``` ```
to update test inputs. to update test inputs.
Make sure we have a fresh build: Make sure we have a fresh build:
$ export BUILDDIR=$TESTDIR/../build $ export BUILDDIR=$TESTDIR/../../build
$ mkdir -p $BUILDDIR $ mkdir -p $BUILDDIR
$ cd $BUILDDIR $ cd $BUILDDIR
$ cmake .. &>/dev/null $ cmake .. &>/dev/null
$ make &> /dev/null $ make &> /dev/null
$ cd $CRAMTMP $ cd $CRAMTMP
$ export STAGEDIR=run_spanning_reference_stagedir
$ export REFERENCE=run_spanning_reference_reference
Prepare content: Prepare content:
$ mkdir stagedir $ mkdir $STAGEDIR
$ echo "content-x" >> stagedir/x $ echo "content-x" >> $STAGEDIR/x
$ for i in `cat $TESTDIR/offset-files.txt`; do xattr -w "$i" "$i" "stagedir/x"; done $ for i in `cat $TESTDIR/offset-files.txt`; do xattr -w "$i" "$i" "$STAGEDIR/x"; done
Create reference DMGs using macOS: Create reference DMGs using macOS:
$ mkdir reference $ mkdir $REFERENCE
$ xattr -w 'attr-key' '__MOZILLA__attr-value-and-a-very-long-string-with-some-padding-to-push-this-across-tworuns-EOL-a' stagedir/x $ xattr -w 'attr-key' '__MOZILLA__attr-value-and-a-very-long-string-with-some-padding-to-push-this-across-tworuns-EOL-a' $STAGEDIR/x
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutila.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutila.hfs
created: */reference/hdiutila.hfs.dmg (glob) created: */hdiutila.hfs.dmg (glob)
$ xattr -w 'attr-key' '__MOZILLA__attr-value-and-a-very-long-string-with-some-padding-to-push-this-across-tworuns-EOL-p' stagedir/x $ xattr -w 'attr-key' '__MOZILLA__attr-value-and-a-very-long-string-with-some-padding-to-push-this-across-tworuns-EOL-p' $STAGEDIR/x
$ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder stagedir reference/hdiutilp.hfs $ hdiutil create -megabytes 5 -fs HFS+ -volname myDisk -srcfolder $STAGEDIR $REFERENCE/hdiutilp.hfs
created: */reference/hdiutilp.hfs.dmg (glob) created: */hdiutilp.hfs.dmg (glob)
Extract reference HFSs: Extract reference HFSs:
$ $BUILDDIR/dmg/dmg extract reference/hdiutila.hfs.dmg reference/hdiutila.hfs > /dev/null $ $BUILDDIR/dmg/dmg extract $REFERENCE/hdiutila.hfs.dmg $REFERENCE/hdiutila.hfs > /dev/null
$ $BUILDDIR/dmg/dmg extract reference/hdiutilp.hfs.dmg reference/hdiutilp.hfs > /dev/null $ $BUILDDIR/dmg/dmg extract $REFERENCE/hdiutilp.hfs.dmg $REFERENCE/hdiutilp.hfs > /dev/null
Ensure that the reference images only differ in the expected ways. (Some sections have minor differences between them - but always in the same places.) Ensure that the $REFERENCE images only differ in the expected ways. (Some sections have minor differences between them - but always in the same places.)
$ xxd reference/hdiutila.hfs | grep -v 000bc140: | grep -v 000bc150: > hdiutila.txt $ xxd $REFERENCE/hdiutila.hfs | grep -v 000bc140: | grep -v 000bc150: | grep -v 000bc040 > hdiutila.txt
$ xxd reference/hdiutilp.hfs | grep -v 000bc140: | grep -v 000bc150: > hdiutilp.txt $ xxd $REFERENCE/hdiutilp.hfs | grep -v 000bc140: | grep -v 000bc150: | grep -v 000bc040 > hdiutilp.txt
$ diff --unified=3 hdiutila.txt hdiutilp.txt $ diff --unified=3 hdiutila.txt hdiutilp.txt
--- hdiutila.txt* (glob) --- *hdiutila.txt* (glob)
+++ hdiutilp.txt* (glob) +++ *hdiutilp.txt* (glob)
@@ -63,12 +63,12 @@ @@ -63,12 +63,12 @@
000003e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000003e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
@ -73,13 +75,13 @@ Ensure that the reference images only differ in the expected ways. (Some section
@@ -48129,7 +48129,7 @@ @@ -48129,7 +48129,7 @@
000bc000: 0000 0000 0000 0000 ff01 0008 0000 0012 ................ 000bc000: 0000 0000 0000 0000 ff01 0008 0000 0012 ................
000bc010: 0000 0001 0006 006d 0079 0044 0069 0073 .......m.y.D.i.s 000bc010: 0000 0001 0006 006d 0079 0044 0069 0073 .......m.y.D.i.s
000bc020: 006b 0001 0000 0000 0003 0000 0002 e101 .k.............. 000bc020:* (glob)
-000bc030:* (glob) -000bc030:* (glob)
+000bc030:* (glob) +000bc030:* (glob)
000bc040: 0000 0000 01f6 0000 0014 0000 41ed 0000 ............A...
000bc050: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000bc050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000bc060: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000bc060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
@@ -48140,15 +48140,15 @@ 000bc070: 0005 0000 007e 0000 0000 0006 0000 0002 .....~..........
@@ -48139,15 +48139,15 @@
000bc0b0: 0069 0076 0061 0074 0065 0020 0044 0069 .i.v.a.t.e. .D.i 000bc0b0: 0069 0076 0061 0074 0065 0020 0044 0069 .i.v.a.t.e. .D.i
000bc0c0: 0072 0065 0063 0074 006f 0072 0079 0020 .r.e.c.t.o.r.y. 000bc0c0: 0072 0065 0063 0074 006f 0072 0079 0020 .r.e.c.t.o.r.y.
000bc0d0: 0044 0061 0074 0061 000d 0001 0010 0000 .D.a.t.a........ 000bc0d0: 0044 0061 0074 0061 000d 0001 0010 0000 .D.a.t.a........
@ -98,7 +100,7 @@ Ensure that the reference images only differ in the expected ways. (Some section
000bc190: 0000 0000 0000 0000 0000 000a 0000 0000 ................ 000bc190: 0000 0000 0000 0000 0000 000a 0000 0000 ................
000bc1a0: 0000 0001 0000 011e 0000 0001 0000 0000 ................ 000bc1a0: 0000 0001 0000 011e 0000 0001 0000 0000 ................
000bc1b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000bc1b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
@@ -48163,8 +48163,8 @@ @@ -48162,8 +48162,8 @@
000bc240: 0000 0000 0048 0046 0053 002b 0020 0050 .....H.F.S.+. .P 000bc240: 0000 0000 0048 0046 0053 002b 0020 0050 .....H.F.S.+. .P
000bc250: 0072 0069 0076 0061 0074 0065 0020 0044 .r.i.v.a.t.e. .D 000bc250: 0072 0069 0076 0061 0074 0065 0020 0044 .r.i.v.a.t.e. .D
000bc260: 0061 0074 0061 0001 0010 0000 0000 0000 .a.t.a.......... 000bc260: 0061 0074 0061 0001 0010 0000 0000 0000 .a.t.a..........
@ -109,7 +111,7 @@ Ensure that the reference images only differ in the expected ways. (Some section
000bc290: 4000 0000 0001 0000 0000 0000 0000 5000 @.............P. 000bc290: 4000 0000 0001 0000 0000 0000 0000 5000 @.............P.
000bc2a0: 4000 4000 0000 0000 0000 0000 0000 0000 @.@............. 000bc2a0: 4000 4000 0000 0000 0000 0000 0000 0000 @.@.............
000bc2b0: 0000 0000 0000 0000 0000 0000 0000 0006 ................ 000bc2b0: 0000 0000 0000 0000 0000 0000 0000 0006 ................
@@ -325053,12 +325053,12 @@ @@ -325052,12 +325052,12 @@
004f5be0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 004f5be0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
004f5bf0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 004f5bf0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
004f5c00: 482b 0004 8000 0000 3130 2e30 0000 0000 H+......10.0.... 004f5c00: 482b 0004 8000 0000 3130 2e30 0000 0000 H+......10.0....
@ -128,4 +130,4 @@ Ensure that the reference images only differ in the expected ways. (Some section
Remove the unneeded dmg: Remove the unneeded dmg:
$ rm reference/hdiutilp.hfs.dmg $ rm $REFERENCE/hdiutilp.hfs.dmg