blob: 92d92024375a92f8d23a8a217d8b8f977f54b589 [file] [log] [blame]
andresp@webrtc.org44eb87e2014-03-17 14:23:22 +00001#!/bin/sh
2#
3# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
4#
5# Use of this source code is governed by a BSD-style license
6# that can be found in the LICENSE file in the root of the source
7# tree. An additional intellectual property rights grant can be found
8# in the file PATENTS. All contributing project authors may
9# be found in the AUTHORS file in the root of the source tree.
10#
11# This script is used to record a tcp dump of running a loop back test.
12# Example use case:
13#
14# $ ./run-server.sh & # spawns a server to serve the html pages
15# # on localhost:8080
16#
17# (recording 3 tests with 5mins and bitrates 1mbps, 2mbps and 3mbps)
18# $ sudo -v # Caches sudo credentials needed
19# # for tcpdump
20# $ export INTERFACE=eth1 # Defines interface to record packets
21# $ export CHROME_UNDER_TESTING=./chrome # Define which chrome to run on tests
22# $ export TEST="http://localhost:8080/loopback_test.html?auto-mode=true"
23# $ record-test.sh ./record1.pcap "$TEST&duration=300&max-video-bitrate=1000"
24# $ record-test.sh ./record2.pcap "$TEST&duration=300&max-video-bitrate=2000"
25# $ record-test.sh ./record3.pcap "$TEST&duration=300&max-video-bitrate=3000"
26
27# Indicate an error and exit with a nonzero status if any of the required
28# environment variables is Null or Unset.
29: ${INTERFACE:?"Need to set INTERFACE env variable"}
30: ${CHROME_UNDER_TESTING:?"Need to set CHROME_UNDER_TESTING env variable"}
31
32if [ ! -x "$CHROME_UNDER_TESTING" ]; then
33 echo "CHROME_UNDER_TESTING=$CHROME_UNDER_TESTING does not seem to exist."
34 exit 1
35fi
36
37if [ "$#" -ne 2 ]; then
38 echo "Usage: $0 <test-url> <network-dump>"
39 exit 1
40fi
41TEST_URL=$1
42OUTPUT_RECORDING=$2
43
44sudo -nv > /dev/null 2>&1
45if [ $? != 0 ]; then
46 echo "Run \"sudo -v\" to cache your credentials." \
47 "They are needed to run tcpdump."
48 exit
49fi
50
51echo "Recording $INTERFACE into ${OUTPUT_RECORDING}"
52sudo -n tcpdump -i "$INTERFACE" -w - > "${OUTPUT_RECORDING}" &
53TCPDUMP_PID=$!
54
55echo "Starting ${CHROME_UNDER_TESTING} with ${TEST_URL}."
56# Using real camera instead of --use-fake-device-for-media-stream as it
57# does not produces images complex enough to reach 3mbps.
58# Flag --use-fake-ui-for-media-stream automatically allows getUserMedia calls.
59$CHROME_UNDER_TESTING --use-fake-ui-for-media-stream "${TEST_URL}"
60kill ${TCPDUMP_PID}