Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement shred --random-source #7005

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

f8ith
Copy link

@f8ith f8ith commented Dec 27, 2024

  • new uucore feature: rand_read
  • removed rand_read_adapter from shuf
  • added random_source to shred

Closes #5711

@sylvestre
Copy link
Contributor

If you are fixing issue #5711 you are doing more than just a refactor.
If so,

@f8ith f8ith changed the title refactor: move random_source to uucore refactor: move random_source to uucore, feat: --random-source shred Dec 30, 2024
@f8ith f8ith changed the title refactor: move random_source to uucore, feat: --random-source shred feat: implement shred --random-source Dec 30, 2024
@sylvestre
Copy link
Contributor

Looks great but seems that it is failing the GNU test:
bash -v util/run-gnu-test.sh tests/uniq/uniq tests/shred/shred-passes to test it:


2024-12-30T08:00:14.3400715Z FAIL: tests/shred/shred-passes
2024-12-30T08:00:14.3400788Z ==============================
2024-12-30T08:00:14.3400792Z 
2024-12-30T08:00:14.3400879Z --- exp	2024-12-30 07:48:09.684864709 +0000
2024-12-30T08:00:14.3400953Z +++ out	2024-12-30 07:48:09.687864717 +0000
2024-12-30T08:00:14.3401022Z @@ -1,6 +1,6 @@
2024-12-30T08:00:14.3401108Z -shred: f: pass 1/3 (random)...
2024-12-30T08:00:14.3401184Z -shred: f: pass 2/3 (random)...
2024-12-30T08:00:14.3401266Z -shred: f: pass 3/3 (random)...
2024-12-30T08:00:14.3401343Z +shred: f: pass  1/3 (random)...
2024-12-30T08:00:14.3401435Z +shred: f: pass  2/3 (random)...
2024-12-30T08:00:14.3401579Z +shred: f: pass  3/3 (random)...
2024-12-30T08:00:14.3401702Z  shred: f: removing
2024-12-30T08:00:14.3401794Z  shred: f: renamed to 0
2024-12-30T08:00:14.3401865Z  shred: f: removed
2024-12-30T08:00:14.3401932Z 1+0 records in
2024-12-30T08:00:14.3402161Z 1+0 records out
2024-12-30T08:00:14.3402308Z 102400 bytes (102 kB, 100 KiB) copied, 3.64241e-04 s, 102 MB/s
2024-12-30T08:00:14.3402396Z --- exp	2024-12-30 07:48:09.698864745 +0000
2024-12-30T08:00:14.3402472Z +++ out	2024-12-30 07:48:09.789864976 +0000
2024-12-30T08:00:14.3402572Z @@ -1,23 +1,9 @@
2024-12-30T08:00:14.3402669Z -shred: f: pass 1/20 (random)...
2024-12-30T08:00:14.3402804Z -shred: f: pass 2/20 (ffffff)...
2024-12-30T08:00:14.3402969Z -shred: f: pass 3/20 (924924)...
2024-12-30T08:00:14.3403099Z -shred: f: pass 4/20 (888888)...
2024-12-30T08:00:14.3403182Z -shred: f: pass 5/20 (db6db6)...
2024-12-30T08:00:14.3403261Z -shred: f: pass 6/20 (777777)...
2024-12-30T08:00:14.3403333Z -shred: f: pass 7/20 (492492)...
2024-12-30T08:00:14.3403413Z -shred: f: pass 8/20 (bbbbbb)...
2024-12-30T08:00:14.3403485Z -shred: f: pass 9/20 (555555)...
2024-12-30T08:00:14.3403563Z -shred: f: pass 10/20 (aaaaaa)...
2024-12-30T08:00:14.3403644Z -shred: f: pass 11/20 (random)...
2024-12-30T08:00:14.3403859Z -shred: f: pass 12/20 (6db6db)...
2024-12-30T08:00:14.3403938Z -shred: f: pass 13/20 (249249)...
2024-12-30T08:00:14.3404011Z -shred: f: pass 14/20 (999999)...
2024-12-30T08:00:14.3404152Z -shred: f: pass 15/20 (111111)...
2024-12-30T08:00:14.3404280Z -shred: f: pass 16/20 (000000)...
2024-12-30T08:00:14.3404415Z -shred: f: pass 17/20 (b6db6d)...
2024-12-30T08:00:14.3404514Z -shred: f: pass 18/20 (eeeeee)...
2024-12-30T08:00:14.3404590Z -shred: f: pass 19/20 (333333)...
2024-12-30T08:00:14.3404673Z -shred: f: pass 20/20 (random)...
2024-12-30T08:00:14.3404743Z -shred: f: removing
2024-12-30T08:00:14.3404819Z -shred: f: renamed to 0
2024-12-30T08:00:14.3404891Z -shred: f: removed
2024-12-30T08:00:14.3405080Z +thread 'main' panicked at src/uucore/src/lib/features/rand_read.rs:61:13:
2024-12-30T08:00:14.3405350Z +reading random bytes from Read implementation failed; error: ReadError: failed to fill whole buffer
2024-12-30T08:00:14.3405465Z +stack backtrace:
2024-12-30T08:00:14.3405599Z +   0: rust_begin_unwind
2024-12-30T08:00:14.3405756Z +   1: core::panicking::panic_fmt
2024-12-30T08:00:14.3405949Z +   2: <uucore::features::rand_read::ReadRng<R> as rand_core::RngCore>::fill_bytes
2024-12-30T08:00:14.3406025Z +   3: uu_shred::uumain
2024-12-30T08:00:14.3406093Z +   4: shred::main
2024-12-30T08:00:14.3406302Z +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
2024-12-30T08:00:14.3406426Z FAIL tests/shred/shred-passes.sh (exit status: 1)
2024-12-30T08:00:14.3406430Z 

at.touch(random_file);
at.write(random_file, "random contents");

ucmd.arg("--random-source=test_random_file")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test to verify the behavior if the file is missing

Copy link

github-actions bot commented Jan 5, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement shred --random-source
2 participants