is it possible to stop the cts and save the current logs - android

I am running android-cts . The commands I run are mentioned below,
cts-tf
run-cts --plan --cts-camera
It is being running for two days . How do I stop the current task and save the existing logs .
Also it is mentioned in documentation ,that the cts logs will be stored in
CTS_ROOT/android-cts/results/start_time.zip
But I dont see a start_time.zip in the location specified .

There are few ways by which you can stop the CTS invocation and result will be generated of your runs,
Unplug the USB Cables from the devices, this will make tradefed to not detect any device and once timeout occurs, it will generate result on testcases and modules it ran.
Kill command, just write the kill in the tradefed, and it will kill and stop the invocation threads for the runs. once that is done, it will generate the result but make sure not to give kill command more than 1 or else it will exit from tradefed without generating the result.

Related

Detecting that android has booted up over adb

I'm trying to detect the successful bootup of an emulated android OS (Google's Android Emulator, sys version 12.0, running on Linux inside Docker) over adb in order to install an app right after boot. I tried the methods mentioned in this thread, but none of them seem to work.
I tried checking for all these props in a loop:
sys.boot_completed
dev.bootcomplete
init.svc.bootanim
service.bootanim.exit
They continue returning 0 even after the device is fully booted up and never return 1.
I also tried adb wait-for-device, but that finished immediately, even though I'm using the "-delay-adb" flag on my emulator (and if I don't use it, the behavior is still the same).
Attempting to install the APK before the boot is finished (right after wait-for-device exits) results in an installation error:
adb: failed to install app.apk: Exception occurred while executing 'install': java.lang.NullPointerException: Attempt to invoke virtual method 'void android.content.pm.PackageManagerInternal.freeStorage(..) on a null object reference'
It I wait for the device to boot and then manually trigger the installation, or if I add a long enough wait time before the installation is attempted, it works without any problems. But I don't want to add an arbitrarily long sleep because this may run on different devices which take different amounts of time to boot up.
Did anybody encounter this behavior?
Do you have any suggestions on how to detect bootup without having to write my own app with a BOOT_COMPLETE listener?
More abstractly, does anybody have a different suggestion on how to install an app in the Android emulator right after boot?
It's a quite an ugly solution, but you could always just attempt to install the application in a loop with some small delay and wait until it succeeds. It's not pretty, but should do the job.
You said that you receive a specific exception when you attempt to install an app during booting. Assuming the same exception is unlikely to happen after booting the phone for some unrelated reason, it should be mostly safe approach to use.
Another thing that comes up to my mind is looking at network traffic, I'd expect android to call home right after booting the system, but that seems much more complicated, and maybe even less reliable, than the "install in a loop" idea.

Run multiple commands at once in RootTools/RootShell?

I'm using the RootTools library, and I need to execute two commands. The first one runs a binary, the second sends SIGINT to it, to kill it.
RootTools (as far as I know) can only have one root shell open at a time, so commands can only be executed one by one. This is a problem, because I have no way to stop my binary after I've ran it.
How can I do any of the following things?
Execute two commands at once, so I can run my kill command when the binary is running
Send SIGINT to my native process some other way (e.g. with a RootTools function)
I need to use RootTools because it's the only way for me to read standard output from my program. If there's another way to do that, though, please comment.
Do you think you can concat the commands?
Let's say I want to launch a find command, but if it takes 5 seconds, I want it to stop:
find / & sleep 5 && kill $!
We can get a better suited one liner, too (i.e. ignore standard error, kill only if needed etc.).
You could also just store the PID and kill it later (be careful, if the daemon stopped to run, his PID can be reused by the OS):
run the daemon in a root shell
my-daemon >/dev/null & echo "PID: $!"
parse the output in Java and store the PID (SharedPreferences?)
var pid = outputLine.split(" ")[1]
later on, stop the daemon with a root shell
kill <pid>

Android CTS - Random test fails

When I run android CTS full test using below command
run cts --plan CTS
Every time it shows different result for some of the packages, I mean some packages some tests passes/fails randomly every time I re-run full test. But when I run package individually (The package in which some tests failed), all the tests passes in it.
Why I am seeing this behavior?
Environment:
OS: Android L
CTS version: 5.1_r7
It happen some time some test failed randomly because some time that test condition is satisfied some time not and some time because of timeout test may fail.
Some cts tests involve specific timeouts set for some event to occur. For example if you are running cts test related to data calls like turning mobile data off/on and timeout to get mobile data connected is set to 10 seconds, then some time this test will pass and sometime it will fail. In this case, increasing that timeout will resolve this issue.
Regarding issue of test case failing when running multiple packages, there could be possibility that test case before failed one has not set device in a neutral/original state for next test. It is a good practice to revert all changes made during a test while exiting a test case.

Running a script as a service from init.rc on Android at boot

In order to execute a script on Android (Samsung Note 10.1 (N8010), 4.4.2) at boot I added the following to the end of the init.rc (unpacking/repacking the boot.img) to have it run as a service:
service test /system/bin/test_script.sh
class main
oneshot
The script looks like this:
#!/system/bin/sh
mkdir /sdcard/test_directory
It is eventually supposed to do something else, but for testing I kept it simple. Permissions are 0755.
The problem though is that the directory /sdcard/test_directory is not being created, which leads me to believe that the service is never being started, i.e, the script is never being executed.
I've already tried numerous things mentioned in other threads.
E.g., adding the line user root to the service, rebooting multiple times (since apparently a service is not being started after booting the device right after flashing the boot.img) or putting the script in different folders like /system/etc/ or /data/local/tmp.
Any idea what could be the problem?
Is it possible to somehow monitor whether the service is actually being started (maybe it is, but the problem lies within the script)?
Is there maybe even a better way to executing a script at boot (device does not have init.d support and I don't want to use an app like Unversal Init.d)?
EDIT:
Don't know why, but it works now.
Moved the script around multiple times, ended up putting it under /data and removing the file extension. Also added some more lines to the script like mkdir /data/local/tmp/test_directory. The directory under /sdcard is not being created though (maybe a permission problem?). Probably the reason, why I thought the script had not been executed, if it has been before.
Question remaining: is there a way to monitor whether a service is actually being started?

init, cron, and am interaction

first time poster here. I have a problem with android. I have cron daemon set up to run a script every once and a while. This script has alarms built in to it that trigger when the script fails or succeeds. The alarms use "am" commands to activate actions on some APKs (one wakes the device, the other plays music and or vibrates).
The script works fine. However, when it is called from the crond it behaves abnormally. dmesg shows init killed the process as per this bit of code:
svc = service_find_by_pid(pid);
if (!svc) {
ERROR("untracked pid %d exited\n", pid);
Obviously my script is not in the init.rc file, nor is crond for that matter, as a service (my phone is locked/reloads init.rc from ramdisk every boot). Is there a manner of fixing this problem without editing the init.rc?
this walkthrough seems like it had you in mind:
http://howto.ccroms.net/howto/cron
As I have always wanted an actual cron installation on my phone, I
worked on patching vixie-cron for just that. Below are the tales of my
adventures:

Categories

Resources