Skip to content

Commit 6c2cf99

Browse files
committed
assert that write_at doesn't change the seek position
1 parent 984afdc commit 6c2cf99

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ jobs:
146146
- name: ensure the channel matches the target branch
147147
run: src/ci/scripts/verify-channel.sh
148148

149+
- name: print kernel/libc versions
150+
if: runner.os == 'Linux'
151+
run: |
152+
uname -a
153+
149154
- name: collect CPU statistics
150155
run: src/ci/scripts/collect-cpu-stats.sh
151156

library/std/src/fs/tests.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use crate::sync::Arc;
3434
use crate::test_helpers::{TempDir, tmpdir};
3535
use crate::time::{Duration, Instant, SystemTime};
3636
use crate::{env, str, thread};
37+
use crate::bstr::ByteStr;
3738

3839
macro_rules! check {
3940
($e:expr) => {
@@ -500,11 +501,13 @@ fn file_test_append_write_at() {
500501
let msg = b"it's not working!";
501502
check!(fs::write(&filename, &msg));
502503
// write_at should work even in in append mode
503-
let f = check!(fs::File::options().append(true).open(&filename));
504+
let mut f = check!(fs::File::options().append(true).open(&filename));
505+
assert_eq!(check!(f.stream_position()), 0);
504506
assert_eq!(check!(f.write_at(b" ", 5)), 3);
507+
assert_eq!(check!(f.stream_position()), 0);
505508

506509
let content = check!(fs::read(&filename));
507-
assert_eq!(&content, b"it's working!");
510+
assert_eq!(ByteStr::new(&content), ByteStr::new(b"it's working!"));
508511
}
509512

510513
#[test]

library/std/src/os/unix/fs/tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use super::*;
2+
use crate::io::Seek;
3+
use crate::bstr::ByteStr;
24

35
#[test]
46
fn read_vectored_at() {
@@ -40,21 +42,23 @@ fn write_vectored_at() {
4042
}
4143
let expected = {
4244
// Open in append mode to test that positioned writes bypass O_APPEND.
43-
let file = fs::File::options().append(true).open(&filename).unwrap();
45+
let mut file = fs::File::options().append(true).open(&filename).unwrap();
4446
let buf0 = b" ";
4547
let buf1 = b"great ";
4648

4749
let iovec = [io::IoSlice::new(buf0), io::IoSlice::new(buf1)];
4850

51+
assert_eq!(file.stream_position().unwrap(), 0);
4952
let n = file.write_vectored_at(&iovec, 11).unwrap();
53+
assert_eq!(file.stream_position().unwrap(), 0);
5054

5155
assert!(n == 4 || n == 11);
5256

5357
if n == 4 { b"pwritev is working!" } else { b"pwritev is great !" }
5458
};
5559

5660
let content = fs::read(&filename).unwrap();
57-
assert_eq!(&content, expected);
61+
assert_eq!(ByteStr::new(&content), ByteStr::new(expected));
5862
}
5963

6064
#[test]

library/std/src/sys/fd/unix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ impl FileDesc {
680680
if let Some(err) = e.raw_os_error()
681681
&& (err == libc::EOPNOTSUPP || err == libc::ENOSYS) =>
682682
{
683+
eprintln!("pwritev2 NOAPPEND error: {err}");
683684
NOAPPEND_SUPPORTED.store(false, core::sync::atomic::Ordering::Relaxed);
684685
return None;
685686
}

src/ci/docker/host-x86_64/pr-check-2/Dockerfile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,5 @@ COPY scripts/sccache.sh /scripts/
2727
RUN sh /scripts/sccache.sh
2828

2929
ENV SCRIPT \
30-
python3 ../x.py check && \
31-
python3 ../x.py clippy ci && \
32-
python3 ../x.py test --stage 1 core alloc std test proc_macro && \
33-
python3 ../x.py doc --stage 0 bootstrap && \
34-
# Build both public and internal documentation.
35-
RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 0 compiler && \
36-
RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 1 library && \
37-
mkdir -p /checkout/obj/staging/doc && \
38-
cp -r build/x86_64-unknown-linux-gnu/doc /checkout/obj/staging && \
39-
RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 1 library/test && \
40-
# The BOOTSTRAP_TRACING flag is added to verify whether the
41-
# bootstrap process compiles successfully with this flag enabled.
42-
BOOTSTRAP_TRACING=1 python3 ../x.py --help
30+
ldd --version && \
31+
python3 ../x.py test --stage 1 std -- "write"

0 commit comments

Comments
 (0)