Files
RedBear-OS/local/recipes/tools/diffutils/source/tests/no-dereference
T
vasilito 068a1ca63e bootloader: rebase onto upstream 1.0.0, sync firmware-loader version
Bootloader fork rebase:
- Base changed from 0.1.0 pre-patched archive to upstream 1.0.0 tag (c7eeb9f)
- Applied 0001-redbear-local-forks.patch (Cargo.toml crate path redirects)
- Applied fix-uefi-alloc-panic.patch equivalents (4 panic!() -> graceful
  error handling in src/main.rs)
- Applied P5-live-preload-cap-1gib.patch (1 GiB cap on live image preload)
- Skipped: P0 GPT partition scan (requires new module + integration),
  P1 timeout/default-resolution, P2 live preload guard (subsumed by
  panic fixes + cap), P3 live image safe read, P4 large ISO boot,
  redox.patch — to be applied in dedicated rebase session.

firmware-loader/Cargo.toml: version 0.1.0 -> 0.3.0 (sync with other
Red Bear custom crates which are at 0.3.0).

fork-upstream-map.toml: bootloader back from PENDING_REBASE to 1.0.0
since the partial rebase matches upstream 1.0.0 content.

fork-upstream-map.toml: base restored to 'main' tracked (was correctly
tracked by build-redbear.sh).
2026-07-11 09:47:59 +03:00

158 lines
4.7 KiB
Bash

#!/bin/sh
# Test the --no-dereference option.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
echo 'Simple contents' > regular1
echo 'Sample contents' > regular2
echo 'Sample contents' > regular3
ln -s regular1 symlink1
ln -s regular1 symlink1bis
ln -s regular2 symlink2
ln -s regular3 symlink3
# Non-recursive comparisons.
# Compare regular file with regular file.
returns_ 1 diff --no-dereference regular1 regular2 > out || fail=1
cat <<EOF > expected || framework_failure_
1c1
< Simple contents
---
> Sample contents
EOF
compare expected out || fail=1
# Compare regular file with symbolic link.
returns_ 1 diff --no-dereference regular1 symlink1 > out || fail=1
cat <<EOF > expected || framework_failure_
File regular1 is a regular file while file symlink1 is a symbolic link
EOF
compare expected out || fail=1
# Compare symbolic link with regular file.
returns_ 1 diff --no-dereference symlink1 regular1 > out || fail=1
cat <<EOF > expected || framework_failure_
File symlink1 is a symbolic link while file regular1 is a regular file
EOF
compare expected out || fail=1
# Compare symbolic links with same value.
diff --no-dereference symlink1 symlink1bis > out || fail=1
compare /dev/null out || fail=1
# Compare symbolic links with different value and different target contents.
LC_ALL=C returns_ 1 diff --no-dereference symlink1 symlink2 > out || fail=1
cat <<EOF > expected || framework_failure_
Symbolic links 'symlink1' -> 'regular1' and 'symlink2' -> 'regular2' differ
EOF
compare expected out || fail=1
# Compare symbolic links with different value and same target contents.
LC_ALL=C returns_ 1 diff --no-dereference symlink2 symlink3 > out || fail=1
cat <<EOF > expected || framework_failure_
Symbolic links 'symlink2' -> 'regular2' and 'symlink3' -> 'regular3' differ
EOF
compare expected out || fail=1
mkdir subdir &&
ln -s loop loop &&
ln -s loop subdir/loop || framework_failure_
diff --no-dereference loop subdir > out || fail=1
compare /dev/null out || fail=1
# Recursive comparisons.
# Compare symbolic link with nonexistent file.
mkdir subdir1a
mkdir subdir1b
ln -s nonexistent subdir1a/foo
ln -s ../regular1 subdir1a/bar
returns_ 1 diff -r --no-dereference subdir1a subdir1b > out || fail=1
cat <<EOF > expected || framework_failure_
Only in subdir1a: bar
Only in subdir1a: foo
EOF
compare expected out || fail=1
# Compare nonexistent file with symbolic link.
mkdir subdir2a
mkdir subdir2b
ln -s nonexistent subdir2b/foo
ln -s ../regular1 subdir2b/bar
returns_ 1 diff -r --no-dereference subdir2a subdir2b > out || fail=1
cat <<EOF > expected || framework_failure_
Only in subdir2b: bar
Only in subdir2b: foo
EOF
compare expected out || fail=1
# Compare regular file with regular file.
mkdir subdir3a
mkdir subdir3b
cp regular1 subdir3a/foo
cp regular2 subdir3b/foo
returns_ 1 diff -r --no-dereference subdir3a subdir3b > out || fail=1
cat <<EOF > expected || framework_failure_
diff -r --no-dereference subdir3a/foo subdir3b/foo
1c1
< Simple contents
---
> Sample contents
EOF
compare expected out || fail=1
# Compare regular file with symbolic link.
mkdir subdir4a
mkdir subdir4b
cp regular1 subdir4a/foo
ln -s ../regular1 subdir4b/foo
returns_ 1 diff -r --no-dereference subdir4a subdir4b > out || fail=1
cat <<EOF > expected || framework_failure_
File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
EOF
compare expected out || fail=1
# Compare symbolic link with regular file.
mkdir subdir5a
mkdir subdir5b
ln -s ../regular1 subdir5a/foo
cp regular1 subdir5b/foo
returns_ 1 diff -r --no-dereference subdir5a subdir5b > out || fail=1
cat <<EOF > expected || framework_failure_
File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
EOF
compare expected out || fail=1
# Compare symbolic links with same value.
mkdir subdir6a
mkdir subdir6b
ln -s ../regular1 subdir6a/foo
ln -s ../regular1 subdir6b/foo
diff -r --no-dereference subdir6a subdir6b > out || fail=1
compare /dev/null out || fail=1
# Compare symbolic links with different value and different target contents.
mkdir subdir7a
mkdir subdir7b
ln -s ../regular1 subdir7a/foo
ln -s ../regular2 subdir7b/foo
LC_ALL=C returns_ 1 diff -r --no-dereference subdir7a subdir7b > out || fail=1
cat <<EOF > expected || framework_failure_
Symbolic links 'subdir7a/foo' -> '../regular1' and 'subdir7b/foo' -> '../regular2' differ
EOF
compare expected out || fail=1
# Compare symbolic links with different value and same target contents.
mkdir subdir8a
mkdir subdir8b
ln -s ../regular2 subdir8a/foo
ln -s ../regular3 subdir8b/foo
LC_ALL=C returns_ 1 diff -r --no-dereference subdir8a subdir8b > out || fail=1
cat <<EOF > expected || framework_failure_
Symbolic links 'subdir8a/foo' -> '../regular2' and 'subdir8b/foo' -> '../regular3' differ
EOF
compare expected out || fail=1
Exit $fail