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

Difference in readlink results #359

Closed
agroce opened this issue Apr 3, 2018 · 9 comments
Closed

Difference in readlink results #359

agroce opened this issue Apr 3, 2018 · 9 comments
Labels

Comments

@agroce
Copy link

agroce commented Apr 3, 2018

import shutil
import pyfakefs.fake_filesystem
import os

ROOT_PATH = "/Volumes/ramdisk/test"

fs = pyfakefs.fake_filesystem.FakeFilesystem()
fs.CreateDirectory('/Volumes')
fs.CreateDirectory('/Volumes/ramdisk')
fs.CreateDirectory('/Volumes/ramdisk/test')
os0 = pyfakefs.fake_filesystem.FakeOsModule(fs)
opener0 = pyfakefs.fake_filesystem.FakeFileOpen(fs)

if False:
    os0 = os
    shutil.rmtree(ROOT_PATH)
    os.mkdir(ROOT_PATH)

component0 = "alpha" 
component1 = "" 
path0 = ROOT_PATH 
path1 = ROOT_PATH 
path0 += os.path.sep + component0 
os0.symlink(path1,path0) 
path0 += os.path.sep + component1 
result = os0.readlink(path0) 

print result

Was playing with fault localization in TSTL, ran across this. OS X yields:

Traceback (most recent call last):
  File "linkbug.py", line 26, in <module>
    result = os0.readlink(path0) 
OSError: [Errno 22] Invalid argument: '/Volumes/ramdisk/test/alpha/'

pyfakefs just returns /Volumes/ramdisk/test

@agroce
Copy link
Author

agroce commented Apr 3, 2018

(will be curious to see if the location of the bug matches what TSTL thinks it is)

@agroce
Copy link
Author

agroce commented Apr 3, 2018

(assuming it's an actual bug)

@mrbean-bremen
Copy link
Member

Just confirmed - it's an actual bug, and can be reproduced under all tested Posix versions (but not under Windows, where it behaves like pyfakefs). I may have a look in the evening...

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Apr 4, 2018
@mrbean-bremen
Copy link
Member

So, out of curiosity - where TSTL thinks the bug was located? Does it evaluate the call stack for that? I know, I could just check the code...

@agroce
Copy link
Author

agroce commented Apr 5, 2018 via email

@mrbean-bremen
Copy link
Member

At least the statements all seem to be in the file creation code, e.g. the test setup, so, yeah, it's off. I'm not sure what the numbers for the branches mean, so I didn't check these. Is the last number a probability?

@agroce
Copy link
Author

agroce commented Apr 5, 2018 via email

@agroce
Copy link
Author

agroce commented Apr 5, 2018 via email

@mrbean-bremen
Copy link
Member

a good small test case is the best fault localization

Yes, I agree, at least in the case of pyfakefs. I basically always write regression tests by slightly adapting your failing tests.

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

No branches or pull requests

2 participants