Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TranSSD-Python
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Container registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Justus Müller
TranSSD-Python
Commits
fe506eb6
Commit
fe506eb6
authored
Jun 13, 2024
by
Justus Müller
Browse files
Options
Downloads
Patches
Plain Diff
fix: Revert to rolling pattern
parent
5b281def
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/drive_handle.py
+10
-25
10 additions, 25 deletions
src/drive_handle.py
src/tests/slack_test.py
+3
-5
3 additions, 5 deletions
src/tests/slack_test.py
with
13 additions
and
30 deletions
src/drive_handle.py
+
10
−
25
View file @
fe506eb6
...
@@ -143,7 +143,7 @@ class DriveHandle:
...
@@ -143,7 +143,7 @@ class DriveHandle:
return
True
return
True
return
False
return
False
def
write_pattern
(
self
,
symbol
:
chr
,
path
:
str
)
->
None
:
def
write_pattern
(
self
,
path
:
str
)
->
None
:
"""
"""
Writes the pattern file to the disk
Writes the pattern file to the disk
...
@@ -151,33 +151,18 @@ class DriveHandle:
...
@@ -151,33 +151,18 @@ class DriveHandle:
symbol (chr): The symbol the pattern file shall be filled with
symbol (chr): The symbol the pattern file shall be filled with
path (str): The path to the pattern file
path (str): The path to the pattern file
"""
"""
print
(
colored
(
f
"
[DriveHandle] Writing a file (
{
path
}
) with 0x
{
symbol
.
encode
().
hex
()
}
pattern to fill the disk.
"
,
"
light_grey
"
))
print
(
colored
(
f
"
[DriveHandle] Writing a file (
{
path
}
) with a rolling pattern to fill the disk.
"
,
"
light_grey
"
))
pattern_start_symbol
:
chr
=
'
A
'
iteration
:
int
=
0
(
_
,
_
,
cluster_size
)
=
self
.
get_allocation_unit_sizes
()
progressbar
=
Spinner
(
'
[DriveHandle] Writing the pattern file
'
)
progressbar
=
Spinner
(
'
[DriveHandle] Writing the pattern file
'
)
with
open
(
path
,
"
wb
"
)
as
file_descriptor
:
write_string
=
str
(
symbol
)
*
1024
*
1024
*
5
# 5 MiB
while
os
.
path
.
getsize
(
path
)
+
cluster_size
<
self
.
get_free_drive_space
():
file_descriptor
=
open
(
path
,
"
w
"
)
current_pattern_symbol
:
chr
=
chr
(
ord
(
pattern_start_symbol
)
+
iteration
)
while
True
:
file_descriptor
.
write
(
current_pattern_symbol
.
encode
()
*
cluster_size
)
try
:
iteration
=
(
iteration
+
1
)
%
26
file_descriptor
.
write
(
write_string
)
file_descriptor
.
flush
()
progressbar
.
next
()
progressbar
.
next
()
except
OSError
as
error
:
if
error
.
errno
==
errno
.
ENOSPC
:
if
len
(
write_string
)
>
1
:
write_string
=
write_string
[:(
len
(
write_string
)
//
2
)]
if
(
self
.
get_free_drive_space
()
==
0
and
len
(
write_string
)
<=
1
):
break
else
:
break
else
:
raise
progressbar
.
finish
()
progressbar
.
finish
()
try
:
file_descriptor
.
close
()
except
OSError
as
error
:
if
error
.
errno
!=
errno
.
ENOSPC
:
raise
print
(
colored
(
"
[DriveHandle] Completed writing the pattern file.
"
,
"
light_grey
"
))
print
(
colored
(
"
[DriveHandle] Completed writing the pattern file.
"
,
"
light_grey
"
))
def
create_overwrite_file
(
self
,
symbol
:
chr
,
path
:
str
)
->
None
:
def
create_overwrite_file
(
self
,
symbol
:
chr
,
path
:
str
)
->
None
:
...
...
This diff is collapsed.
Click to expand it.
src/tests/slack_test.py
+
3
−
5
View file @
fe506eb6
...
@@ -31,10 +31,9 @@ class SlackTest(DecisionTest):
...
@@ -31,10 +31,9 @@ class SlackTest(DecisionTest):
# create pattern
# create pattern
pattern_file_path
:
str
=
f
'
{
self
.
drive_handle
.
get_path
()
}
transsd-slacktest-pattern
'
pattern_file_path
:
str
=
f
'
{
self
.
drive_handle
.
get_path
()
}
transsd-slacktest-pattern
'
self
.
drive_handle
.
write_pattern
(
'
A
'
,
pattern_file_path
)
self
.
drive_handle
.
write_pattern
(
pattern_file_path
)
self
.
drive_handle
.
flush_cache
()
print
(
colored
(
"
[SlackTest] Waiting 120s for the OS to flush the write cache.
"
,
"
light_grey
"
))
print
(
colored
(
"
[SlackTest] Waiting 120s for the OS to flush the write cache.
"
,
"
light_grey
"
))
time
.
sleep
(
120
)
pattern_file_clusters
:
list
=
[]
pattern_file_clusters
:
list
=
[]
if
self
.
_check_cluster_overlap
:
if
self
.
_check_cluster_overlap
:
pattern_file_clusters
=
self
.
drive_handle
.
get_clusters_for_file
(
pattern_file_path
)
pattern_file_clusters
=
self
.
drive_handle
.
get_clusters_for_file
(
pattern_file_path
)
...
@@ -43,9 +42,8 @@ class SlackTest(DecisionTest):
...
@@ -43,9 +42,8 @@ class SlackTest(DecisionTest):
# delete file
# delete file
self
.
drive_handle
.
delete_file
(
pattern_file_path
)
self
.
drive_handle
.
delete_file
(
pattern_file_path
)
self
.
drive_handle
.
flush_cache
()
print
(
"
[SlackTest] Waiting 120s for OS to clean up the disk...
"
)
print
(
"
[SlackTest] Waiting 120s for OS to clean up the disk...
"
)
time
.
sleep
(
12
0
)
time
.
sleep
(
6
0
)
print
(
colored
(
"
[SlackTest] File should be removed from disk without remainder.
"
,
"
light_grey
"
))
print
(
colored
(
"
[SlackTest] File should be removed from disk without remainder.
"
,
"
light_grey
"
))
# create overwriting file
# create overwriting file
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment