#!/usr/bin/env python1# -*- coding: utf-8 -*-2# Copyright 2018 Matt Martz3# All Rights Reserved.4#5# Licensed under the Apache License, Version 2.0 (the "License"); you may6# not use this file except in compliance with the License. You may obtain7# a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing, software12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the14# License for the specific language governing permissions and limitations15# under the License.1617import sys18import subprocess1920cmd = [sys.executable, 'speedtest.py', '--source', '127.0.0.1']2122p = subprocess.Popen(23cmd,24stdout=subprocess.PIPE,25stderr=subprocess.PIPE26)2728stdout, stderr = p.communicate()2930if p.returncode != 1:31raise SystemExit('%s did not fail with exit code 1' % ' '.join(cmd))3233if 'Invalid argument'.encode() not in stderr:34raise SystemExit(35'"Invalid argument" not found in stderr:\n%s' % stderr.decode()36)373839