Git Product home page Git Product logo

os1-tests's Introduction

Testing Framework for OS 234123 - HW 1

Created by Ronen Sandler and Amitai Frey

Important

Please do not immediately contact us if the framework/tests don't work for you. They have been verified by multiple students and therefore are probably accurate.

Nevertheless, if you are convinced you have found a bug please explain exactly what the bug is and provide an exact section in the assignment / piazza post that proves you are correct. Otherwise, we will simply not answer your questions.

This is done in order to help us from solving bugs for everyone, so we can apply our time to fix the actual bugs we might still have and to benefit the rest of the class.

Requirements

  • Smash executable
  • The attached generated tests
  • Python 3
  • Ability & maturity to debug code yourself

Basic Usage

  1. Copy the tests framework folder to your machine, with the tests
  2. In that folder, run: ./test.py -smash="<your_smash>" -test="unit"
  3. Check the output for diffs/equal prompts

Advanced Usage

  • In order to run a specific test by its name, run: ./test.py -smash ="<your_smash>" -test="<test_name>". For example: ./test.py -smash ="smash" -test="unit/jobs"
  • In order to generate tests of your own, create a test.in and test.exp files, where the test.exp file matches by regex the expected output line by line.
  • Additionaly, you may specify a (flat) directory of your choice containing .in and .exp files in the with the command ./test.py -smash="<your_smash>" -test="<directory_path>"

Details

  • This framework utilizes difflib's SequenceMatcher, but enhances it by comparing each line by regex. This helps us test on different machines with different pids without having to "hack" them to get what we want . These regexs include:
    • \d+ for pids and secs numbers
    • \[, \], \(, \) for escaping these chars so the regex matches them plainly.
    • Of course the framework supports standard regex matching. The sky is the limit!
  • Additionally, the framework supports comparing regex groups in multiple lines. This can help make sure you get the same output in different calls by the same test. For example, in order to make sure that the pid stays the same, you can write: smash> smash pid is (?P <pid>\d+) in the *.exp file every time you run showpid. The framework will make sure that the regex group pid always has the same value.
  • This framework also relies on setting up the /tmp/smash_test directory as we expect it, with random files for copying and checking.
  • You can comment the input files by starting the line with #
  • You can add lines to the input file that will be run in the python framework directly by starting them with !, for ex: !time.sleep(2) will cause the framework to sleep for 2 seconds.
  • In order to send Ctrl-C or Ctrl-Z signals, simply write in a separate line in the input file CtrlC or CtrlZ respectively.
  • Also added to the framework is my_sleep.c, which is compiled during setup and copied to the test dir. It is run by: my_sleep <n> where n is the number of seconds it will sleep, printing the time that has passed every two seconds.
  • The tests that are contained in this repository consist of unit tests written for common edge-cases. If you have additional test cases that are not checked here, please open a pull request for us with them and we will be happy to add them to the repository.

os1-tests's People

Contributors

amitaifrey avatar ronensand avatar talsk avatar ronensandler avatar

Stargazers

 avatar  avatar NightFalls avatar  avatar  avatar Aviv Eldan avatar

Watchers

 avatar  avatar

os1-tests's Issues

[Suggestion] Add original test line to the test output for easier debugging

So obviously it is extremely hard to debug long tests since you can't know exactly where you failed.
I tried to play with some changes, and figured the following does a decent job (A change to line 84):

    for line_number, line in enumerate(i.readlines()):
        time.sleep(0.1)
        p.stdin.writelines([bytes("printf \"\\nTest line: " + str(line_number) + "\\n\"\n", "utf-8")])

The trick is sending smash an echo command that will print the current test line number. This will require re-running all tests to get the new .exp files.
This is not perfect mainly because it really clutters the output, but it did help me find where I failed way more easily than I would have otherwise.
What do you think?

ls is not working as intended

  1. according to piazza, ls sort order should be the same as alphasort function, which is different than the bash sort order that you are using.
    https://piazza.com/class/kg7wfbyqnoc73t?cid=173

  2. it seems your ls receives an argument as path, the same as bash. according to exercise, for ls:
    If any number of arguments were provided with this command then they will be ignored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.