Giter Club home page Giter Club logo

compiler-design-eth-tests's Introduction

compiler-design-eth-tests

Shared tests for the compiler design projects, HS21.

Use

The repository contains a copy of the tests I personally use for the projects. Each folder contains a whole copy of the file where we can write our own tests.

To use them, you can simply replace the whole studenttests.ml with the one provided here.

Contribute

Please, if you find any problem or bug in the provided tests, open an issue. If you know how to fix them, you can also go ahead and open a PR with the fix.

If you have some other tests you have already written, you can either open a PR or contact me. In any case, I will keep an eye at the course's forum in orther to gather all tests that are published there.

Setup

If you want to integrate these tests into your project instead of copying the files you can follow these steps:

  1. Clone this repo anywhere you like (let the path to the cloned repo be called <repo_path> and let <project_path> be the directory, which contains the makefile for the current homework)
  2. Create a symbolic link to <repo_path> called sharedtests in <project_path>
  3. Adapt the Makefile to include these tests:
     main.native: gradedtests.ml studenttests.ml main.ml driver.ml backend.ml util/platform.ml
-       ocamlbuild -Is util,x86,ll,grading -libs unix,str,nums main.native -use-menhir
+       ocamlbuild -Is util,x86,ll,grading,sharedtests,sharedtests/0{2,3,4,5,6} -libs unix,str,nums main.native -use-menhir
 
 main.byte: gradedtests.ml studenttests.ml main.ml driver.ml backend.ml util/platform.ml
-       ocamlbuild -Is util,x86,ll,grading -libs unix,str,nums main.byte -use-menhir
+       ocamlbuild -Is util,x86,ll,grading,sharedtests,sharedtests/0{2,3,4,5,6} -libs unix,str,nums main.byte -use-menhir

(Note: depending on the makefile, the additional directories might need to be added at the top in a DIRS variable or similar) 4. Add our shared suite to main.ml:

-let suite = ref (Studenttests.provided_tests @ Gradedtests.graded_tests)
+let suite = ref (
+  Studenttests.provided_tests @
+  Gradedtests.graded_tests @ 
+  Sharedtests.shared_suite)
  1. Edit the global_prefix in the file Test_config of this repo to represent the relative path from inside <project_path> to <repo_path>. By default it is setup such that <repo_path> and <project_path> have the same parent directory.
  2. Optional: If you use merlin you should add these lines to the .merlin file:
+B _build/sharedtests/**
+S sharedtests/**

And now make test should also run our tests :)

compiler-design-eth-tests's People

Contributors

da-gazzi avatar dbernhard-0x7cd avatar joennlae avatar liuzikai avatar multimodcrafter avatar nicdard avatar thbwd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

compiler-design-eth-tests's Issues

Movq into immediate

All the jmp_ind_x tests contain a movq with an immediate as the location. However immediate values and labels are not valid locations as by the X86lite documentation.

I think there is also a typo on line 110. It says cs_not instead of cc_not

Thanks for sharing your tests!

(duplicate) Fibonacci Timeout

The Fibonacci test, calculates the 30th Fibonacci number. On our implementation, this gives sometimes a timeout (5s). Maybe lower it to Fibonacci of 20, which works more reliably.

Fibonacci Timeout

The Fibonacci test times out after 5 seconds. My implementation requires at least a minute to complete the test.
Either my implementation is horrendously slow or yours is quite fast or this test is too ambitious. Could you confirm that you can indeed run this test in the 5 second constraint?

Authors file?

@dbernhard-0x7CD tagging you since you are adding a good quantity of new tests.

I was thinking that if the other assignments are also having tests, it can be good to add an author file maybe? Or license on top of each file?

I would however keep all the file for each assignment in one file only so we can simply copy paste the whole thing to try out our implementation.

Otherwise we can have multiple suites, each of them gathering the test of an author such as:

let nicdard_provided_tests = [ ... ]
let dbernhard_provided_tests = [ ... ]

and then merge all of them (since those are simply list of assertion test).

cc_shr_max ZF flag

I believe that the test cc_shr_max tests for the wrong ZF flag.
ZF should be only set (true) iff the result is zero. Int64.max_int in binary is a zero followed by 63 ones.
Shifting right by 63 or more would indeed result in a zero. But the test only shifts right by 3, which clearly is non-zero.
Either the test was meant to shift by 63, test ZF: false or I misunderstood something.

Must reference equality really be supported?

@dbernhard-0x7CD's tests include comparing references, for example, in

https://github.com/nicdard/compiler-design-eth-tests/blob/main/05/dbernhard/equality.oat#L25

I wonder, though, whether supporting this is really necessary for this homework. Although the rules Typ_Eq and Typ_Neq imply that it should be supported, the provided frontend does not implement this (see lines 246 - 252). Also, I did not find any indication anywhere else that we're supposed to add this.

Am I missing something?

cc_not

Shouldn't this test expect the result to be -2?

; ("cc_not", Gradedtests.csi_test 2 (cc_not ()))

It moves 1 to Rax which is 0b00..001. If this is negated bitwise we get 0b11..110 which corresponds to -2.

If i compile this assembler:

.text
.global program

program:
    pushq %rbp
    movq %rsp, %rbp

    movq $1, %rax
    not %rax

    movq %rbp, %rsp
    popq %rbp
    ret

.data  

The Rax register contains -2 as signed int64_t after execution.

Edit: I misunderstood the first argument to Gradedtests.cs_test which is not the expected answer, but the number of instructions to execute. Nevertheless now we have a testcase which tests if the sign flag is unaffected by notq.

Global Prefix

I like that the tests for HW3 have a prefix variable for where the files are located.

Could we agree to extend this system with a global prefix?

My goal is to have this repository outside of my personal hw directories but be able to access the tests from there.
If we have one global ml file with a prefix variable, which everybody can configure to a value to their liking, the repo could be cloned anywhere, and from then on, updating would be as easy as a pull. Also, for future homeworks, the only setup one needed to do would be to configure the main and makefile.

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.