Skip to content
Snippets Groups Projects
Commit 73ba3cb9 authored by David Grellscheid's avatar David Grellscheid
Browse files

Cleanup some lines after discord comments

parent 45885251
No related branches found
No related tags found
No related merge requests found
......@@ -25,23 +25,26 @@ it, 'and what is the use of a book,' thought Alice 'without pictures or
conversations?'
"""
test_sample = "Did you know that the moon is made of cheese?"
test_sample = "Did you know that the moon is made of cheese?\0\0\0"
def test_1():
with open("test1.fs", 'r+b') as f:
with open("test1.fs", 'w+b') as f:
format(f) # clear the file system
try:
for i in range(7):
# Add 7 files (is max with the original capacity)
save(f, f"alice{i}.txt", f"content{i}")
# Remove 1 file, there should be more space now
remove(f, f"alice{i}.txt")
# try adding another file
save(f, f"hello.txt", f"Hello World!")
# Check that the new file is there
assert load(f, "hello.txt") == "Hello World!"
# Remove 1 file, there should be more space now
remove(f, "alice3.txt")
# try adding another file
save(f, "hello.txt", "Hello World!")
# Check that the new file is there
content = load(f, "hello.txt")
except Exception as e:
print(f"Test 1 failed: {e}")
content = ""
assert content == "Hello World!"
def test_2():
......@@ -50,7 +53,6 @@ def test_2():
format(f)
save(f, "test.txt", test_sample)
content = load(f, "test.txt")
content = content.decode('utf-8')
assert content == test_sample
......@@ -58,13 +60,15 @@ def test_3():
# test that block was not zeroed out when deleted
with open("test_remove_not_zeroed_out.fs", 'w+b') as f:
format(f)
f.seek(0)
clean_state = f.read()
save(f, "test.txt", test_sample)
remove(f, "test.txt")
# Check that the file system is not fully zeroed out
f.seek(0)
content = f.read()
assert any(byte != 0 for byte in content), "File system is fully zeroed out after removal"
assert content != clean_state, "File system is fully zeroed out after removal. It should not be"
def test_4():
......@@ -76,13 +80,11 @@ def test_4():
# Test that the content is the same
content = load(f, "link.txt")
content = content.decode('utf-8')
assert content == test_sample
# Test that removing the original file does not affect the hard link
remove(f, "test.txt")
content = load(f, "link.txt")
content = content.decode('utf-8')
assert content == test_sample
# test that the file can be removed
......@@ -100,7 +102,7 @@ print(f"* Use xxd {backingfile} to inspect contents")
print("*" * 60)
print()
#test_1()
#test_2()
#test_3()
#test_4()
# test_1()
# test_2()
# test_3()
# test_4()
......@@ -59,11 +59,11 @@ def _set_num_files(f, n):
def _get_num_linked_files(f):
... # Oppgave 4
pass # Oppgave 4
def _set_num_linked_files(f, n):
... # Oppgave 4
pass # Oppgave 4
......@@ -193,4 +193,4 @@ def hard_link(f, existing_file, link_name):
link_name (str): The name of the new hard link.
"""
#TODO: implement this function
...
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment