-
Notifications
You must be signed in to change notification settings - Fork 62
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
Half the generated files are empty? #43
Comments
I'm facing same issue with all grammars I tested they generated empty files, but I don't know it's intended or not. |
Hi @kaby76 and @CityOfLight77 It's not a surprise if you look carefully into the grammar to generate test cases from. In case of VerilogGenerator, the start rule used in the example is // START SYMBOL
source_text
: description* EOF
; It means, that Although this random decision about zero or more quantifier expansion is quite useful deeper in the derivation tree to avoid infinite recursions, at the beginning, around the I hope this helps! @CityOfLight77 If it doesn't solve your problem with empty files, please share the grammar and I'll look into it. Cheers, |
For |
Hi @kaby76 It's not a bell curve but it's an (1/x)^n curve (in this case (1/2)^n), which is exactly what we expect from quantifiers by definition/implementation. The generation of quantifiers happens according to the following pseudo code: source_text = UnparserRule(name='source_text')
while random_decision():
source_text += UnparserRule(name='description') It means, that the probability of the generation of one |
Thanks. That explains quite a bit of what the generated code is doing. I can now follow through on what |
@kaby76 I was just about to leave a comment guiding you to models, if you wanted to tweak the "let's flip a coin" default approach. You can write your own decision model that has the same API as DefaultModel . Every random decision of the generated fuzzer (e.g., how to chose an alternative from https://github.com/renatahodovan/grammarinator/blob/master/grammarinator/generate.py#L237-L238 As the documentation of models is incomplete (so to say), let me introduce I know that the above is a bit brief, but I hope it helps. BTW, there is also a subclass of class VerilogModel(grammarinator.runtime.DispatchingModel):
def quantify_source_text(self, node, idx, min, max):
yield
yield
yield (And this would create test cases that always contained exactly three descriptions. The rest of the quantifiers would still use the flip-the-coin approach.) |
I'm using the grammar here and generated tests using the latest on
master
:I'm not sure I understand why half of the files generated have zero character length.
The text was updated successfully, but these errors were encountered: