Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Modify tests to complete faster.
Browse files Browse the repository at this point in the history
On development environment time improved from 560 seconds to 70.
  • Loading branch information
Pasi Miettinen committed May 20, 2016
1 parent d7e9c3d commit 801bb7a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 109 deletions.
50 changes: 10 additions & 40 deletions tests/test_acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_acq_result_file_name(sample_file):

def run_acq_test(init_doppler, init_code_phase,
prns, file_format,
freq_profile='normal_rate',
freq_profile='low_rate',
skip_samples=None, skip_ms=None):

if skip_samples is not None:
Expand Down Expand Up @@ -100,57 +100,27 @@ def test_acqusition_prn1_m1000():
run_acq_test(-1000., 0., [1], '2bits')


def test_acqusition_prn32_m1000():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(-1000., 0., [32], '2bits')


def test_acqusition_prn5_m1000():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(-1000., 0., [5], '2bits')

def test_acqusition_prn1_0():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(0., 0., [1], '2bits')


def test_acqusition_prn32_0():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(0., 0., [32], '2bits')


def test_acqusition_prn5_0():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(0., 0., [5], '2bits')

def test_acqusition_prn1_p1000():
def test_acqusition_prn5_p1000():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(1000., 0., [1], '2bits')
run_acq_test(1000., 0., [5], '2bits')


def test_acqusition_prn32_p1000():
"""
Test GPS L1C/A acquisition
def test_skip_params():
"""
run_acq_test(1000., 0., [32], '2bits')
Test different skip parameters:
--skip_samples
and
--skip_ms

def test_acqusition_prn5_p1000():
"""
Test GPS L1C/A acquisition
"""
run_acq_test(1000., 0., [5], '2bits')


run_acq_test(1000, 0, [1], '1bit', skip_samples=1000)
run_acq_test(1000, 0, [1], '1bit', skip_ms=50)
2 changes: 1 addition & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def get_skip_params(skip_samples, skip_ms):
return (skip_param, skip_val)



def generate_2bits_x4_sample_file(filename):
sample_block_size = 4 # [bits]
s_file = np.memmap(filename, offset=0, dtype=np.uint8, mode='r')
Expand Down Expand Up @@ -135,6 +134,7 @@ def generate_sample_file(gps_sv_prn, init_doppler,
params += ['--generate', str(generate)]
params += ['--output', sample_file]
params += ['--profile', freq_profile]
params += ['-j 4']
print params
with patch.object(sys, 'argv', params):
iqgen.main()
Expand Down
4 changes: 4 additions & 0 deletions tests/test_file_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@

SAMPLE_FILE_NAME = 'sample_data_in_piksi_format.bin'


def test_file_format_1bit():
"""
Test different file formats: '1bit'
"""
run_acq_test(1000, 0, [1], '1bit')


def test_file_format_2bits():
"""
Test different file formats: '2bits'
"""
run_acq_test(1000, 0, [1], '2bits')


def test_file_format_1bitx2():
"""
Test different file formats: '1bit_x2'
"""
run_acq_test(1000, 0, [1], '1bit_x2')


def test_file_format_2bitsx2():
"""
Test different file formats: '2bits_x2'
Expand Down
16 changes: 11 additions & 5 deletions tests/test_freq_profiles.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Copyright (C) 2016 Swift Navigation Inc.
#
# This source is subject to the license found in the file 'LICENSE' which must
# be be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

from test_acquisition import run_acq_test
from test_common import generate_piksi_sample_file
from peregrine.gps_constants import L1CA
from peregrine.samples import load_samples

import peregrine.defaults as defaults
import os

def test_custom_rate():
run_acq_test(-4000, 0, [1], '2bits', 'custom_rate')


def test_low_rate():
run_acq_test(-2000, 0, [2], '2bits', 'low_rate')


def test_normal_rate():
run_acq_test(2000, 0, [3], '2bits', 'normal_rate')

Expand Down
1 change: 0 additions & 1 deletion tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

import peregrine.navigation

def test_navigation():
assert True, "Fill me in!"
24 changes: 1 addition & 23 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,11 @@
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

import peregrine.run
import peregrine.defaults as defaults
import peregrine.gps_constants as gps
import sys
import cPickle
import os
import numpy as np

from test_acquisition import run_acq_test
from mock import patch
from shutil import copyfile
from test_common import generate_sample_file, \
run_peregrine,\
propagate_code_phase, \
get_sampling_freq
run_peregrine

def test_skip_params():
"""
Test different skip parameters:
--skip_samples
and
--skip_ms
"""
run_acq_test(1000, 0, [1], '1bit', skip_samples = 1000)
run_acq_test(1000, 0, [1], '1bit', skip_ms = 50)

def test_tracking():
prn = 15
Expand All @@ -59,4 +38,3 @@ def test_tracking():

# Clean-up.
os.remove(samples_filename)

86 changes: 47 additions & 39 deletions tests/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,50 +75,43 @@ def get_tr_loop_res_file_name(sample_file, prn, band):
return tr_loop_fn


def run_track_test(expected_lock_ratio, init_doppler, init_code_phase,
prns, file_format,
freq_profile='low_rate',
def run_track_test(samples_file, expected_lock_ratio, init_doppler,
init_code_phase, prn, file_format, freq_profile,
skip_samples=None, skip_ms=None,
pipelining=None, short_long_cycles=None):

bands = fileformat_to_bands(file_format)

skip_param, skip_val = get_skip_params(skip_samples, skip_ms)

for prn in prns:
samples_filename = generate_sample_file(prn, init_doppler,
init_code_phase,
file_format, freq_profile, generate=10)
run_peregrine(samples_file, file_format, freq_profile,
skip_param, skip_val, skip_tracking=False,
pipelining=pipelining, short_long_cycles=short_long_cycles)

run_peregrine(samples_filename, file_format, freq_profile,
skip_param, skip_val, skip_tracking=False,
pipelining=pipelining, short_long_cycles=short_long_cycles)

for band in bands:
dopp_ratio = 1
if band == "l2c":
dopp_ratio = l2 / l1
run_tracking_loop(prn, band, init_doppler * dopp_ratio, init_code_phase,
samples_filename, file_format, freq_profile, 0,
pipelining=pipelining,
short_long_cycles=short_long_cycles)

#code_phase = propagate_code_phase(init_code_phase,
#get_sampling_freq(freq_profile),
#skip_param, skip_val)

check_per_track_results(expected_lock_ratio, samples_filename, prn, bands,
pipelining, short_long_cycles)

check_tr_loop_track(expected_lock_ratio, samples_filename, prn, bands,
pipelining, short_long_cycles)

# Clean-up.
os.remove(get_acq_result_file_name(samples_filename))
for band in bands:
os.remove(get_peregrine_tr_res_file_name(samples_filename, prn, band))
os.remove(get_tr_loop_res_file_name(samples_filename, prn, band))
os.remove(samples_filename)
for band in bands:
dopp_ratio = 1
if band == "l2c":
dopp_ratio = l2 / l1
run_tracking_loop(prn, band, init_doppler * dopp_ratio, init_code_phase,
samples_file, file_format, freq_profile, 0,
pipelining=pipelining,
short_long_cycles=short_long_cycles)

#code_phase = propagate_code_phase(init_code_phase,
#get_sampling_freq(freq_profile),
#skip_param, skip_val)

check_per_track_results(expected_lock_ratio, samples_file, prn, bands,
pipelining, short_long_cycles)

check_tr_loop_track(expected_lock_ratio, samples_file, prn, bands,
pipelining, short_long_cycles)

# Clean-up.
os.remove(get_acq_result_file_name(samples_file))
for band in bands:
os.remove(get_peregrine_tr_res_file_name(samples_file, prn, band))
os.remove(get_tr_loop_res_file_name(samples_file, prn, band))


def check_per_track_results(expected_lock_ratio, filename, prn, bands,
Expand Down Expand Up @@ -179,9 +172,24 @@ def test_tracking():
Test GPS L1C/A and L2C tracking
"""

run_track_test(0.7, 555, 0, [1], '2bits_x2')
run_track_test(0.3, 333, 0, [1], '2bits_x2', pipelining=0.5)
run_track_test(0.3, -100, 0, [1], '2bits_x2', short_long_cycles=0.5)
prn = 1
init_doppler = 555
init_code_phase = 0
file_format = '2bits_x2'
freq_profile = 'low_rate'

samples = generate_sample_file(prn, init_doppler,
init_code_phase,
file_format, freq_profile, generate=5)

run_track_test(samples, 0.6, init_doppler, init_code_phase, prn, file_format,
freq_profile)
run_track_test(samples, 0.3, init_doppler, init_code_phase, prn, file_format,
freq_profile, pipelining=0.5)
run_track_test(samples, 0.3, init_doppler, init_code_phase, prn, file_format,
freq_profile, short_long_cycles=0.5)

os.remove(samples)

# test --no-run
run_tracking_loop(1, L1CA, 0, 0, 'dummy', '2bits_x2', 'low_rate', 0,
Expand Down

0 comments on commit 801bb7a

Please sign in to comment.