diff --git a/README.md b/README.md index 785dbb0..d11246c 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@
  • Contributing
  • Disclaimer
  • @@ -138,6 +139,11 @@ Contributions are always welcome! Feel free to open an issue or submit a pull re driver to be loaded with a real signature, and is going to be automatically signed with a test certificate during the build process. **In case you're using BitLocker, be sure to have your recovery key at hand before rebooting.** +### Testing +```shell +py.test test.py +``` + ### Formatting - C: `clang-format -i -style=Microsoft *.h *.c` - Python: `black *.py` diff --git a/test.py b/test.py new file mode 100644 index 0000000..d951ea8 --- /dev/null +++ b/test.py @@ -0,0 +1,48 @@ +import hashlib +import ksh +import os +import psutil +import subprocess + +MD5SUM = "d8a9e839260c00e65cc91be886638871" + + +def test_driver_test(): + ksh.test() + + +def test_driver_cp(): + from_file = "LICENSE" + to_file = "hund" + ksh.cp( + os.path.abspath(".") + "\\" + from_file, os.path.abspath(".") + "\\" + to_file + ) + assert os.path.exists(to_file) + assert hashlib.md5(open(to_file, "rb").read()).hexdigest() == MD5SUM + + +def test_driver_mv(): + from_file = "hund" + to_file = "katze" + ksh.mv( + os.path.abspath(".") + "\\" + from_file, os.path.abspath(".") + "\\" + to_file + ) + assert os.path.exists(to_file) + assert not os.path.exists(from_file) + assert hashlib.md5(open(to_file, "rb").read()).hexdigest() == MD5SUM + + +def test_driver_rm(): + path = os.path.abspath(".") + "\\" + "katze" + ksh.rm(path) + assert not os.path.exists(path) + + +def test_driver_pkill(): + notepad = "notepad.exe" + process = subprocess.Popen([notepad]) + pid = process.pid + ksh.pkill(pid) + for proc in psutil.process_iter(): + if proc.name() == notepad: + assert pid != proc.pid