Test in init.rc if a property is unset - android

How can you check if a property is unset in init.rc:
In the following example test.b is not yet set
on property:test.a=1 && test.b=<unset>
# do something

Reading queue_property_triggers1 it seems that you can't. You'll probably need to change your code logic.

Related

Why can I not create variables in a GNU make 'define' directive

I'm trying to build a GNU Make Canned Recipe, like so:
define this-will-fail
my_var=1
$(info your variable is $(my_var))
endef
$(this-will-fail)
This causes an error *** missing separator. Stop.
However, the following works as expected:
define why-does-this-work
$(eval my_var=1)
$(info your variable is $(my_var))
endef
$(why-does-this-work)
by printing your variable is 1.
I'm looking at AOSP's build system and frequently see usage of eval paired with define. What's the relationship between these two items, and why can I not create variables "normally" when using define?
The answer stems from a simple point with big ramifications - a makefile has two dialects, 1) the make language itself and 2) the shell language you use for stuff like invoking gcc.
A reminder of the normal make "rule" syntax:
targets : prerequisites
recipe
While the make target and prerequisites is in make
syntax, the stuff in the recipe is in the shell syntax, not make syntax.
This explains why you cannot do stuff like assign make variables as part of a recipe, as so:
all: the_dependencies_of_all
this_will_not_work := because_the_shell_does_not_know_what_this_line_means
In the shell syntax bits, make does three special text manipulations, and then the remaining string is passed verbatim to the shell. The three steps are
deal with escaped newlines (e.g. backslash followed by newline)
run any make functions (like $(filter ....) and $(eval ..)
expand any make target variables (like $#)
In the normal case, this 3-steps-then-shell processs happens once per recipe line, so each line of your makefile recipe is run in a different shell (hence why some calls to make will spawns many /bin/sh sub-processes).
Manipulation #2 above explains why you can use eval inside a recipe to add some make syntax to your recipe. Eval will turn into an empty string, which will cause no problems with the shell, but make will have evaluated the string inside your statement, so stuff like variable definitions is possible.
The precise moment this evaluation happens is a bit tricky to pin down - it seems to happen when the variable is first expanded, which itself depends upon where you reference that variable in your makefile. Perhaps someone can clarify this a bit more, since when this happens has been ramifications for invocations of make that use the -j flag to run multiple recipe lines in parallel
More Info:
https://www.gnu.org/software/make/manual/html_node/Rule-Introduction.html#Rule-Introduction
https://www.gnu.org/software/make/manual/html_node/Recipe-Syntax.html#Recipe-Syntax
https://www.gnu.org/software/make/manual/html_node/Splitting-Recipe-Lines.html#Splitting-Recipe-Lines

I Want to use variable in cucumber feature file

There are scenarios in feature files wherein I've use the text "Foo" and on click its open a new page. this text sometime changes to "Foo1" or "Foo2" or to something else. to avoid line by line change in feature file for "Foo" to "Foo1" or "Foo2" is there any way that I can globally declare variable in top/bottom of the feature file where I can set the required text in variable on fly and I shall start executing my test instantly?
This change exist in many feature files and around 1000 lines in feature file. To get solution for this, I try on setting environment variables but I couldn't reach all the way till end this issue to solve. So can anyone help me on this?
Thanks in advance
What if you do the replacement in your step implementation instead? Then you could have the desired value in a separate file or pass it as arguments. That way you don't need to hard code the values.
Could scenario outlines help you in any way or is the value only changing depending on external changes?
My first thought was scenario outlines like #homaxto said.
Then I thought you might want to affect it by which system you are connected to. You can do this through configuration. I have done this with Fig_Newton.
You can either set an environment varaible or use one in the commandline. Or you can use #hook type tags. With a hook tag, you can have a tag at the top of a feature file that you can use to set a variable that affects how the steps operate (but it needs to be handled inside the step).

MonkeyTalk Android Detect String Containing \n for Button Tap

I am using MonkeyTalk to automate some user test cases for my Android app. Everything is working fine except for when I try and detect a button containing this string:
"Connect\n(Code Required)"
I get this error:
FAILURE: Unable to find Button(Connect\n(Code required))
If I change the button to "Connect" and perform a tap on that value MonkeyTalk has no trouble, but something about the line break must be throwing it off.
After some searching I found this thread that confirmed my suspicious about the line break. There was one suggested fix here, to set the default encoding to UTF-8 (Select the Project > File > Properties > Resources)
However this did not work for me.
I have also tried to find the button using a wildcard like so:
"*(Code Required)"
But this does not seem to be supported either.
Maybe there is an alternative line break character I could use?
Thanks in advance for the help!
Maybe there's a carriage return in there? I know in most text editors a new line actually consists of (carriage return)+(newline).
Also take a look at this:
TextView carriage return not working
Also, depending on how flexible your requirements are, you could use the #N MonkeyId replacement to get the Nth button.
IN javascript you can use below command
app.button("buttonname").tap(x, y);
Use android:contentDesxription="your_component_id" in your view xml file definition or view.setContentDescription("your_component_id"); directly on view in code to make it easy to access in MonkeyTalk.

how to get environment variable value in Android.mk?

Any possibility to get environment variable value inside Android.mk?
For example
#export MYBASEDIR=/home/whoami/base
And, inside Android.mk How to get MYBASEDIR value ?
Bear with me for very basic question.
All environment variables are imported by make as make macros automatically.
So, just use $(MYBASEDIR) in the makefile.

How can I get user defined Environment variables?

I would like to use self defined Environment variables in my source code. I use System.getenv() to do this and the code line looks like this. Log.d("MyTest","== MyEnv " + System.getenv("AP") + " ANDROID_ASSETS:" + System.getenv("ANDROID_ASSETS"));
before I execute my code I define my AP variable with export: export AP="12345" and the this is my output of set command
ANDROID_ASSETS=/system/app
ANDROID_BOOTLOGO=1
ANDROID_DATA=/data
ANDROID_PROPERTY_WORKSPACE=9,32768
ANDROID_ROOT=/system
AP=12345
...
Then I execute my code and I get this line from logcat
D/MyTest( 5363): == MyEnv null ANDROID_ASSETS:/system/app
The value for my defined Environment variable is null. Any suggestions on why it didn't work?
Export command works for one session only, not for a whole system. You can't set environment variables that way. getprop/setprop doesn't work neither.
I had similar problem and found that easiest way to pass some arguments from console is to do something like:
echo "12345" > /sdcard/myapp/args/AP
Then read this file from Java.

Categories

Resources