regression/tests/test_csma_one_subnet.py
author Craig Dowell <craigdo@ee.washington.edu>
Wed, 26 Mar 2008 00:36:58 -0700
changeset 2848 a1e7347d31cc
parent 2847 f0aedbbb037b
permissions -rw-r--r--
quiet diffs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2846
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
#! /usr/bin/env python
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
"""Regression test csma-one-subnet."""
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
import os
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
2847
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
     7
def rmdir(dir):
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
     8
    if os.path.exists(dir):
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
     9
        files = os.listdir(dir)
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    10
        for file in files:
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    11
            if file == '.' or file == '..':
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    12
                continue
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    13
            path = dir + os.sep + file
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    14
            os.remove(path)
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    15
        os.rmdir(dir)
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    16
2846
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
def run(verbose, generate):
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
    """Execute a test."""
2847
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    19
2846
7689461231ac start of regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
    os.system("./waf --cwd regression/traces --run csma-one-subnet")
2847
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    21
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    22
    if generate:
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    23
        rmdir("knowns")
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    24
        os.rename("traces", "knowns")
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    25
        os.system("tar -cjf tests/csma-one-subnet.bz2 knowns/")
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    26
        rmdir("knowns")
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    27
        return 0
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    28
    else:
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    29
        rmdir("knowns")
f0aedbbb037b trace generation and comparison
Craig Dowell <craigdo@ee.washington.edu>
parents: 2846
diff changeset
    30
        os.system("tar -xjf tests/csma-one-subnet.bz2 knowns/")
2848
a1e7347d31cc quiet diffs
Craig Dowell <craigdo@ee.washington.edu>
parents: 2847
diff changeset
    31
        return os.system("diff -q knowns traces")