How to pass a string argument to `krun` in K framework? - kframework

In the K framework, one can use the -c switch of krun to pass to the initial configuration other variables then the default $PGM. For example, one may have this code:
configuration <T color="yellow">
<k color="green"> $PGM:Pgm </k>
<something> $SOMEARG:Int </something>
</T>
and run kompile imp.k; krun tests/sum.imp -cSOMEARG=3, and the $SOMEARG variables gets the value 3. However, I run into problems when I tried to pass a string:
configuration <T color="yellow">
<k color="green"> $PGM:Pgm </k>
<something> $SOMEARG:String </something>
</T>
After kompile, the command
krun tests/sum.imp -cSOMEARG=\"hello\" --debug
outputs:
org.kframework.utils.errorsystem.KEMException: [Error] Critical: Parser returned a non-zero exit code: 113
Stdout:
Stderr:
[Error] Inner Parser: Parse error: unexpected token 'hello'.
Source(<command line: -e>)
Location(1,1,1,6)
at org.kframework.utils.errorsystem.KEMException.create(KEMException.java:130)
at org.kframework.utils.errorsystem.KEMException.criticalError(KEMException.java:39)
at org.kframework.krun.KRun.externalParse(KRun.java:237)
at org.kframework.krun.KRun.parseConfigVars(KRun.java:161)
at org.kframework.krun.KRun.run(KRun.java:77)
at org.kframework.krun.KRunFrontEnd.run(KRunFrontEnd.java:95)
at org.kframework.main.FrontEnd.main(FrontEnd.java:62)
at org.kframework.main.Main.runApplication(Main.java:118)
at org.kframework.main.Main.runApplication(Main.java:108)
at org.kframework.main.Main.main(Main.java:56)
How do I pass a string argument?

This is a bug in the version of the option parsing library we are using that causes it to try to unquote quotation marks even though that is actually the role of the shell. It is fixed in the latest version of the options library. You can track the progress of the bug fix here: https://github.com/kframework/k/pull/1335
I expect it will be fixed in the very near future.

Related

What's a bad file descriptor?

I have the next system swi-prolog in a file call 'system.pl';
helloWorld :- read(X), write(X).
And i want to test it, then, i write it;
:- begin_tests(helloWorld_test).
test(myTest, true(Output == "hello")) :-
with_output_to(string(Output), getEntry).
:- end_tests(helloWorld_test).
getEntry :-
open('testcase.test', read, Myfile),
set_input(Myfile),
process_create(path(swipl), ['-g', 'main', '-t', 'halt', 'system.pl'], [stdin(stream(Myfile)), stdout(pipe(Stream))]),
copy_stream_data(Stream, current_output),
close(Myfile).
In testcase.test is contained the following;
hello.
Ok, now, when i call to swipl -g run_tests -t halt system.pl i get it;
% PL-Unit: helloWorld_test ERROR: -g helloWorld: read/1: I/O error in read on stream user_input (Bad file descriptor)
ERROR: c:/programasvscode/prolog/programasrandom/system.pl:40:
test myTest: wrong answer (compared using ==)
ERROR: Expected: "hello"
ERROR: Got: ""
done
% 1 test failed
% 0 tests passed
ERROR: -g run_tests: false
Warning: Process "c:\swipl\bin\swipl.exe": exit status: 2
I tried use read/2 with current_input but i got the same with the difference of read/2 instead read/1
What does mean it? any solve?

In jmeter: getting Error invoking bsh method: eval

BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: import org.apache.jmeter.services.FileServer; String path=FileServer.getFileSer . . . '' : Attempt to access property on undefined variable or class name 2022-01-27 19:50:51,923 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: import org.apache.jmeter.services.FileServer; String path=FileServer.getFileSer . . . '' : Attempt to access property on undefined variable or class name
JMETER BEANSHELL CODE: (Beanshell post processor)
import org.apache.jmeter.services.FileServer;
String path=FileServer.getFileServer().getBaseDir();
var1= vars.get("userid");
var2= vars.get("username");
var3= vars.get("userfullname");
var4= ${exam_id};
f = new FileOutputStream("C://apache-jmeter-5.4.1/apache-jmeter-5.4.1/bin/Script4.csv",true);
p = new PrintStream(f);
this.interpreter.setOut(p);
p.println(var1+ "," +var2 + "," +var3 + "," +var4);
f.close();
Change this line:
var4= ${exam_id};
to this one:
var4= vars.get("exam_id");
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so it worth considering migrating to Groovy.
If you run this code with more than 1 thread (virtual user) you will face a race condition resulting in data corruption when multiple threads will be writing into the same file. JMeter provides sample_variables property allowing to write variables values to the .jtl results file, if you need to store the data in a separate file - go for Flexible File Writer

An error occurred when executing Randomwalk2dmobility in NS3

I am a newbie to NS3. I want to understand the execution status of handover in the Randomwalk2d module and visualize it. The default is two Ue and two enb, but errors will always occur during execution. Can anyone help me solve the problem?
This is my code link:https://drive.google.com/file/d/163NQOyvs0bTh2J4P9_vpS4Y7iqocB3HJ/view?usp=sharing
When I execute the command : ./waf --run scratch/lte_handover --visualize, the following error appear
../scratch/lte_handover.cc:In funtion 'int main(int, char**)':
../scratch/lte_handover.cc:296:78: error: expected ')' before ';' token
"Bounds",RectangleValue (Rectangle (0,2000,0,2000)));
^
Build failed
->task in 'lte_handover' failed with exit status 1 (run with -v to display more information)
Follow the instructions to enter the command :./waf --run scratch/lte_handover -v, and the following information appears
Several tasks use the same identifier. Please check the information on
https://waf.io/apidocs/Task.html?highlight=uid#waflib.Task.Task.uid
object 'SuidBuild_task'(
{task 139759060979784: SuidBuild_task -> }) defined in 'tap-creator'
object 'SuidBuild_task'(
{task 139759060980008: SuidBuild_task -> }) defined in 'tap-creator'
object 'SuidBuild_task'(
{task 139759065638504: SuidBuild_task -> }) defined in 'tap-creator'
Seems that you have an extra ) in that line above. You are not closing this command as you commented all the lines
ueMobility.SetPositionAllocator ("ns3::RandomRectanglePositionAllocator", // <-- close
ueMobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel","Bounds", RectangleValue (Rectangle (0,2000,0,2000)));

Could not find method getAaptOptions() for arguments [] on task

I am trying to use the Tinker.When I use the Gradle order "buildTinkerPatchRelease",but after it started,something goes wrong.And it stop.
Could not find method getAaptOptions() for arguments [] on task ':app:processReleaseResources' of type com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.
Because of this , I cannot make a patch apk to continue Tinker.
"I've tried change the buildToolsVersion and update my buildTool ,the latest version is 29.0.2,but it still didn't work.
"
> Task :app:preBuild UP-TO-DATE
> Task :app:preReleaseBuild UP-TO-DATE
> Task :app:compileReleaseAidl NO-SOURCE
> Task :app:checkReleaseManifest
> Task :app:compileReleaseRenderscript NO-SOURCE
> Task :app:generateReleaseBuildConfig
> Task :app:mainApkListPersistenceRelease
> Task :app:generateReleaseResValues
> Task :app:generateReleaseResources
> Task :app:createReleaseCompatibleScreenManifests
> Task :app:processReleaseManifest
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:23:9-27:56 Warning:
activity#com.tencent.bugly.beta.ui.BetaActivity#tools:name was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:23:9-27:56 Warning:
activity#com.tencent.bugly.beta.ui.BetaActivity#tools:configChanges was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:23:9-27:56 Warning:
activity#com.tencent.bugly.beta.ui.BetaActivity#tools:theme was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:29:9-39:20 Warning:
provider#com.tencent.bugly.beta.utils.BuglyFileProvider#tools:name was tagged at AndroidManifest.xml:29 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:29:9-39:20 Warning:
provider#com.tencent.bugly.beta.utils.BuglyFileProvider#tools:authorities was tagged at AndroidManifest.xml:29 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:29:9-39:20 Warning:
provider#com.tencent.bugly.beta.utils.BuglyFileProvider#tools:exported was tagged at AndroidManifest.xml:29 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml:29:9-39:20 Warning:
provider#com.tencent.bugly.beta.utils.BuglyFileProvider#tools:grantUriPermissions was tagged at AndroidManifest.xml:29 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml Warning:
meta-data#android.support.FILE_PROVIDER_PATHS#tools:name was tagged at AndroidManifest.xml:0 to replace other declarations but no other declaration present
C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\src\main\AndroidManifest.xml Warning:
meta-data#android.support.FILE_PROVIDER_PATHS#tools:resource was tagged at AndroidManifest.xml:0 to replace other declarations but no other declaration present
> Task :app:tinkerProcessReleaseManifest
tinker add tinker_id_patch-1.0.0 to your AndroidManifest.xml C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\build\intermediates\merged_manifests\release\AndroidManifest.xml
tinker add com.example.odm.tinkerdemo.application.MyApplication to dex loader pattern
tinker gen AndroidManifest.xml in build/intermediates/tinker_intermediates/AndroidManifest.xml
> Task :app:tinkerProcessReleaseResourceId
we build app apk with apply resource mapping file C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\build\bakApk/app-0915-20-24-52/app-release-R.txt
> Task :app:tinkerSupportProcessReleaseManifest
manifestPath: C:\Users\ODM\Documents\GitHub\android-databinding\TinkerDemo\app\build\intermediates\merged_manifests\release\AndroidManifest.xml
app version:1.0.0.1
Remove TINKER_ID tinker_id_patch-1.0.0
tinkerSupport add com.example.odm.tinkerdemo.application.MyApplication to dex loader pattern
tinkerSupport gen AndroidManifest.xml in build/intermediates/bugly_intermediates/AndroidManifest.xml
> Task :app:mergeReleaseResources
> Task :app:processReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Could not find method getAaptOptions() for arguments [] on task ':app:processReleaseResources' of type com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I expect I can fix the stange problem! May someone can give me a hand?
You can try this,
dependencies {
classpath 'com.tencent.bugly:tinker-support:1.2.0'
}
app buildgradle:
implementation 'com.tencent.tinker:tinker-android-lib:1.9.14'
root buildgradle:
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "com.tencent.bugly:tinker-support:1.2.0"
Hope it helps?

The PAKCS REPL consider something undefined, but the module defining it is loaded

The problem
My code includes a module called Tests which defines the following:
broken :: SetRBT Int
broken = insertRBT 1 $ emptySetRBT (<)
I can evaluate broken in the REPL:
All> broken
RedBlackTree.RedBlackTree (_impl#==#Prelude.Eq#Prelude.Int) (_impl#==#Prelude.Eq#Prelude.Int) (_def#<#Prelude.Ord (_inst#Prelude.Ord#Prelude.Int)) (RedBlackTree.Tree RedBlackTree.Black 1 RedBlackTree.Empty RedBlackTree.Empty)
All>
I cannot, however, evaluate the RHS of broken's definition:
All> insertRBT 1 $ emptySetRBT (<)
PAKCS_Main_Exp.curry, line 3.18: Error:
Undefined type RedBlackTree.RedBlackTree
ERROR occurred during parsing!
All>
Or so I believed, until I tried attaching a type signature:
All> insertRBT 1 $ emptySetRBT (<) :: SetRBT Int
RedBlackTree.RedBlackTree (_impl#==#Prelude.Eq#Prelude.Int) (_impl#==#Prelude.Eq#Prelude.Int) (_def#<#Prelude.Ord (_inst#Prelude.Ord#Prelude.Int)) (RedBlackTree.Tree RedBlackTree.Black 1 RedBlackTree.Empty RedBlackTree.Empty)
All>
I'm fine with having to attach type signatures when needed, or more generally, to do whatever the error messages suggest I should do. But how would I know to interpret the above error message as meaning "you've got to attach a type signature"? More generally, what does that type error even mean, given that (see below) RedBlackTree is loaded?
What I am loading
Each time I start PAKCS I run :l All. That loads a module which reads, in relevant part,
module All ( module M
) where
import FiniteMap as M
import SetRBT as M
import RedBlackTree as M
import Tests as M
That idiom lets me load all the things that I need (there are others) without producing a long prompt.
If I run :modules it looks like RedBlackTree should be defined:
All> :modules
Currently loaded modules:
All (loaded from ./.curry/pakcs/All.pl)
Prelude (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/Prelude.pl)
FiniteMap (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/FiniteMap.pl)
SetRBT (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/SetRBT.pl)
RedBlackTree (loaded from /home/jeff/logic/curry/install/pakcs-2.0.2/lib/.curry/pakcs/RedBlackTree.pl)
Tests (loaded from ./.curry/pakcs/Tests.pl)
All>
You must tell the interpreter to add referenced modules.
All> :add RedBlackTree SetRBT
... some messages ...
All SetRBT RedBlackTree> insertRBT 1 $ emptySetRBT (<)
and it will work.