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

Refactor & Add test for watcher_unix #218

Merged
merged 16 commits into from
Aug 16, 2023

Conversation

Dust1404
Copy link
Member

@Dust1404 Dust1404 commented Aug 10, 2023

Fix #216

同时修复了添加 test 过程中发现的 MacOS 的内存限制错误的 Bug(memoryLimit 单位不统一导致)。

重构了 watcher_unix 的代码,合并了 Linux 和 MacOS 版本的公共代码,将差异的部分提出成两个文件。加了一些注释。

watcher_unix 加了点测试用例,防止之后的贡献再出现上次的疏漏。

目前的测试点有如下:

  • 编译型语言可以正常运行(.c)
  • 解释型语言可以正常运行(.sh)
  • 静态内存检查 MLE
  • 支持不限制内存空间
  • TLE 自动杀死子进程
  • 文件名带空格
  • 符号链接(绝对路径或相对路径)
  • 重定向 IO
  • 运行时错误(访问无效内存)

欢迎添加更多的测试用例增大测试覆盖率。

unix/watcher_linux.cpp Outdated Show resolved Hide resolved
unix/watcher_linux.cpp Outdated Show resolved Hide resolved
@Dust1404 Dust1404 marked this pull request as draft August 10, 2023 12:33
@Dust1404
Copy link
Member Author

Dust1404 commented Aug 10, 2023

更新:符号链接不用处理,open 时会自动处理符号链接。已添加测试用例进行验证。


内存限制还有点问题,原来没考虑负数的情况。明天再改改。
以及还有符号链接的问题,比如 /usr/bin/python3 其实是符号链接,解析时会认为不是可执行文件而报错 程序无法运行 。明天我评估下这个问题,如果改动大的话我再额外开一个 PR。

@Dust1404 Dust1404 changed the title Fix #216 & Add test for watcher_unix Refactor & Add test for watcher_unix Aug 10, 2023
@Dust1404 Dust1404 marked this pull request as ready for review August 10, 2023 15:42
@alphagocc alphagocc merged commit 3a73359 into Project-LemonLime:master Aug 16, 2023
21 of 22 checks passed
alphagocc pushed a commit that referenced this pull request Aug 16, 2023
* add test for watcher_unix

* fix watcher_unix

* add test for watcher_unix

* resolve comments

* add comment for parse fileName

* refactor watcher_unix

* add unlimited memory & TLE test

* fix macos build

* format code

* no need to resolve symlink

* add testcases

* minor fix

* minor fix (consistent)

* remove duplicate include

* add more testcases for watcher_unix

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

Successfully merging this pull request may close these issues.

[BUG] 0.3.4.3 版本在 Linux 下测评会报错「程序不能运行」
2 participants