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

tst: fix file descriptor leaks #5568

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tst/testbugfix/2006-10-23-t00163.tst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ gap> List([0..255], i-> ReadByte(f)) = a;
true
gap> RemoveFile(fnam);
true
gap> CloseStream(f);
11 changes: 7 additions & 4 deletions tst/testinstall/compressed.tst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ gap> rawfname := Filename(dir, "rawtest.g.gz");;
# Let us check when we have written a compressed file by checking the gzip header
# We need raw file access to do this, so we use 'IO'. We stub out this part of the
# test if IO is not loaded
#@if IsPackageLoaded("IO")
gap> checkGzippedFile := function(fname, expected)
> local ins, str;
> if not IsPackageLoaded("IO") then return true; fi;
> # Use 'ValueGlobal' to avoid warnings about undefined functions
> ins := ValueGlobal("IO_File")(fname, "r");
> str := ValueGlobal("IO_Read")(ins, 2);;
> ins := IO_File(fname, "r");
> str := IO_Read(ins, 2);
> IO_Close(ins);
> # All gzipped files should start with these two characters
> return (str = [CharInt(31),CharInt(139)]) = expected;
> end;;
#@else
gap> checkGzippedFile := ReturnTrue;;
#@fi
gap> str := "hello\ngoodbye\n";;

# Write an uncompressed file
Expand Down
6 changes: 6 additions & 0 deletions tst/testinstall/read.tst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ gap> SeekPositionStream(x, 3);
true
gap> ReadAll(x);
"lo\ngoodbye\ni like pies\n"
gap> CloseStream(x);

#
gap> x := InputTextString("hello\ngoodbye\ni like pies\n");;
gap> ReadLine(x);
"hello\n"
Expand Down Expand Up @@ -65,6 +68,9 @@ gap> SeekPositionStream(x, 3);
true
gap> ReadAll(x);
"lo\ngoodbye\ni like pies\n"
gap> CloseStream(x);

#
gap> x := StringFile(Filename( DirectoriesLibrary("tst"), "example.txt" ));;
gap> ReplacedString(x, "\r\n", "\n");
"hello\ngoodbye\ni like pies\n"
Expand Down
1 change: 1 addition & 0 deletions tst/testinstall/streams.tst
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ gap> file := InputTextFile( fname );;
gap> repeat
> line := ReadLine( file );
> until line = fail;
gap> CloseStream(file);

# Invalid files
gap> PrintTo("/", "out");
Expand Down