Closed Bug 1050110 Opened 10 years ago Closed 9 years ago

[MTBF][MozDevice] Need modification for adding logcat, devices, forward controls

Categories

(Firefox OS Graveyard :: MTBF, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: wachen, Unassigned)

References

Details

There are many lines of code in the MTBF driver like this:
  dmesg_cmd = "adb shell dmesg > dmesg" + str(current_round)
  os.system(logcat_cmd)
OR
  default_port = 2828
  current_ports = []
  p = subprocess.Popen(['adb', 'forward', '--list'], stdout=subprocess.PIPE)
  for response in p.communicate()[0].split('\n'):
    if ':' in response:
      current_ports.append(int(response.split(' ')[1].split(':')[1]))
    while default_port in current_ports:
      default_port += 1

There are lack of detailed forward, detailed logcat, detailed devices related functions in mozDevice. I would like to add 2~3 class regarding forward, logcat, and devices.
Blocks: MTBF-2014Q3
Summary: [MTBF][MozDevice] Need modification → [MTBF][MozDevice] Need modification for adding logcat, devices, forward controls
wlach and ahal,

Sorry for bothering. I want to add some functions in mozdevice for DeviceManagerADB.py

What I want to add is:
1. forward:
  a. better way to do the forwarding:
     for example, we are currently using tcp:2828 format to forward port. However, marionette is doing 2828 and default tcp. It will be strange that we need to recombine them. 
  b. detection of current port in use.

2. logcat:
  a. ways to output logcat
  b. ways to get different/extracted logcat

3. devices:
  a. ways to assign different devices different things

My changes will include the above mentioned but not limited to it. There will be more functions finished based on adb fuctions.

I'd like to know is there any coding standards or concerns. If we all agree on something, I will go ahead and create the code for review. Please advice.
Flags: needinfo?(wlachance)
Flags: needinfo?(ahalberstadt)
Hi Walter, thanks for looking into this! From what I can tell, devicemanagerADB can already do most of the stuff that you mentioned below? Reply inline.

(In reply to Walter Chen[:ypwalter][:wachen] from comment #1)
> What I want to add is:
> 1. forward:
>   a. better way to do the forwarding:
>      for example, we are currently using tcp:2828 format to forward port.
> However, marionette is doing 2828 and default tcp. It will be strange that
> we need to recombine them. 
>   b. detection of current port in use.

Is dm.forward(local_port, remote_port) not enough? If no local_port is used, this function uses a random one and returns it. Note this ability was added recently, so it's possible you were looking at an out of date mozdevice.
 
> 2. logcat:
>   a. ways to output logcat
>   b. ways to get different/extracted logcat

There is a dm.getLogcat() function defined in the base class. It is a little broken on b2g at the moment, see bug 1050211.
 
> 3. devices:
>   a. ways to assign different devices different things

Typically this is done by spawning one dm instance per device and pass in the `deviceSerial` attribute to the constructors. I don't think we want to support one instance controlling multiple devices.
 
> My changes will include the above mentioned but not limited to it. There
> will be more functions finished based on adb fuctions.

Sounds good! Maybe what you mean will be more clear to me once I see the patch. Again thanks for contributing.
Flags: needinfo?(ahalberstadt)
I'm not sure if I have much to add to what ahal said, but I would also recommend checking out the mozdevice docs:

http://mozbase.readthedocs.org/en/latest/mozdevice.html
Flags: needinfo?(wlachance)
I will check things you two mentioned. And, I will come up with more details again before I started to code. Thanks for advices, those are pretty helpful.
About adb forwarding:

1. Is the functionality of doing random port in https://github.com/mozilla/gecko-dev/blob/master/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py? I didn't see it there. Is it possible that you tell me the latest mozdevice repository is?

2. Currently, there are few commands for "adb forward"
  a. adb forward --list           - list all forward socket connections.
  b. adb forward <local> <remote> - forward socket connections
  c. adb forward --no-rebind <local> <remote>
  d. adb forward --remove <local> - remove a specific forward socket connection
  e. adb forward --remove-all     - remove all forward socket connections
I am thinking of adding functionality of (a), (d), and (e). However, if random port binding is supported, I might only want to do (d) and (e)

3. better way to do the forwarding: my thoughts is to do the following.
   def forward(self, local, remote, type="tcp")
   or
   def forward(self, port, type="tcp")

   In this way, we could do a forward(2828). The reason behind this is that we need consistence between some mozilla tools. When we come to one point that we want to integrate marionette / gaiatest / mozdevice into MTBF. We have some code like this the following.
   md.forward("tcp:" + str(port), "tcp:2828")
   m = Marionette('localhost', port)

   I don't think the style to combine this is good though... Another reason for this is that we usually only use tcp for port binding. I will suggest to do in this way so that marionette and mozdevice can have some consistence. Also, other programming need this resource can better integrate it.
about adb logcat, I see the function now. I will use it as for now. Even though I do want to put other parameters in that functions: Priority, -t, -f, ...

about devices, I want to have one instance controlling over one devices, but I might start multiple instances for multile devices (1-to-1 relation between instances and devices) In that case, what should I do to assign environment variable "ANDROID_SERIAL" or "-s (device name)"
moved to Q4. We have implemented something, but not yet ready.
Blocks: MTBF-2014Q4
No longer blocks: MTBF-2014Q3
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
Blocks: MTBF-2015Q1
No longer blocks: MTBF-2015Q1
You need to log in before you can comment on or make changes to this bug.