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

Smoke Testing #211

Merged
merged 14 commits into from
Jan 15, 2024
Merged

Smoke Testing #211

merged 14 commits into from
Jan 15, 2024

Conversation

sanchezocegueda
Copy link

Check for unreachable code by running uclid with the --smoke flag.

@@ -47,6 +47,8 @@ import scala.collection.immutable._
import lang.{Identifier, Module, _}
import uclid.Utils.ParserErrorList
import com.typesafe.scalalogging.Logger
import java.io.{File, FileWriter}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this import?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It was left over from my first attempt at smoke testing (where I rewrote the file); I removed it now.

val file = scala.io.Source.fromFile(srcFile)
// TODO: parse line by line instead of loading the complete file into a string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't delete this todo please

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I must have deleted it by accident! It's back in its rightful place now :D

@@ -432,6 +446,12 @@ object UclidMain {
passManager.addPass(new ModuleEliminator(mainModuleName))
// Expands (grounds) finite_forall and finite_exists quantifiers
passManager.addPass(new FiniteQuantsExpander())
// test unreachable code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an argument for putting this here? Would it be better to put it before all the passes? after?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no. I moved it there because the LTL specification check was originally part of SmokeRemover, and it would not work when the passes were in that part of the code. Now that we have the SmokeAnalyzer pass to perform the checks, it works just fine (and it is a lot faster). I moved this block of code to the top of createCompilePassManager again.

package uclid
package lang

class SmokeAnalyzePass extends RewritePass {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're doing an analysis use the analysis pass class, not the rewrite pass class. More efficient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@FedericoAureliano
Copy link
Contributor

It looks mostly good! I added some comments that I'd like you to address but then I think I'm happy with it.

Also, maybe it is worth adding an example/test. I'm not sure exactly what the test would look like though. @polgreen what do you think?

Copy link
Contributor

@polgreen polgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look again once you've fixed Federico's comments, but overall looks good, but it definitely needs tests.

Tests should:

  • check that it's identifying the correct number of reachable/unreachable lines of code correctly for a few different configurations of UCLID files (what does it do if it has multiple modules? Does it only do the main module? Does it do all the modules? Does it work for inlined procedures? What about not-inlined procedures? Check that it works correctly with assumptions as well as with )
  • check that the error message for LTL is correctly thrown

A question:

  • Does it remove pre/post conditions? Because those can result in things being unreachable if we do no-inlining of procedures, because we generate an "assume post condition" after the point where the procedure was called. So you might not be getting correct results for those cases if you are removing the pre/post conditions before we no-inline the procedures

src/main/scala/uclid/UclidMain.scala Outdated Show resolved Hide resolved
@polgreen
Copy link
Contributor

is this ready for review again?

@FedericoAureliano
Copy link
Contributor

This looks mostly good to me! I don't know about introducing the shell files for installations (I'm fine with doing it but not sure this pull request is the right place for that). The tests look good too but are not in the CI. I think that is fine too, though.

@polgreen are we good to merge?

@polgreen
Copy link
Contributor

Can you make the tests run in the CI before you merge, please? And then it's good to merge. We tend to break things that don't get tested by the CI

@FedericoAureliano
Copy link
Contributor

I added SmokeSpec to the CI. Tests pass. I think we should merge.

@polgreen polgreen merged commit 13bfea2 into uclid-org:master Jan 15, 2024
2 checks passed
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.

3 participants