Commit cc326776 authored by Federico Sismondi's avatar Federico Sismondi

modified the DATADIR, TMPDIT and LOGDIR creation & imports in favor of a centralized approach

cleaned up some useless print lines
parent 41c8dbf5
......@@ -2,7 +2,6 @@ Copyright (c) 2017 INRIA / Universite de Rennes 1
Contact address: <federico.sismondi@inria.fr>
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/or redistribute the software under the terms of the CeCILL
......
......@@ -7,6 +7,7 @@ from setuptools import setup, find_packages
PACKAGE = 'ttproto'
LICENSE = 'CeCILL'
# Read version without importing for coverage issues
def get_version(package):
""" Extract package version without importing file
......@@ -55,6 +56,7 @@ setup(
long_description_content_type='text/markdown',
packages=find_packages(),
classifiers=CLASSIFIERS,
include_package_data=True, # see MANIFEST.in
install_requires=[
'pyyaml',
'requests',
......
......@@ -3,12 +3,13 @@ import os
import errno
import logging
__version__ = '0.1.4'
__version__ = '0.1.5'
PACKAGE_DIR = os.path.dirname(os.path.realpath(__file__))
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
DATADIR = os.path.join(PACKAGE_DIR, "data")
TMPDIR = os.path.join(PACKAGE_DIR, "tmp")
LOGDIR = os.path.join(PACKAGE_DIR, "log")
LOG_LEVEL = logging.INFO
LOG_FORMAT = '%(levelname)s %(name)s [%(threadName)s] %(message)s'
......@@ -17,7 +18,10 @@ logging.basicConfig(level=LOG_LEVEL, format=LOG_FORMAT)
# lower versbosity of pika's logs
logging.getLogger('pika').setLevel(logging.WARNING)
logging.info("ttproto base dir : %s "%PACKAGE_DIR)
for d in TMPDIR, DATADIR, LOGDIR:
logging.info("Creating %s directory." % d)
try:
os.makedirs(d)
except OSError as e:
......
......@@ -44,6 +44,7 @@ import traceback
from os import path
from importlib import import_module
from ttproto import PACKAGE_DIR
from ttproto.core.data import Data, DifferenceList, Value
from ttproto.core.dissector import (Frame, Capture, is_protocol,
ProtocolNotFound)
......@@ -61,7 +62,6 @@ __all__ = [
]
TESTCASES_SUBDIR = 'testcases'
TTPROTO_DIR = 'ttproto'
TC_FILE_EXTENSION = '.py'
EVERY_TC_WILDCARD = 'td_*' + TC_FILE_EXTENSION
......@@ -715,7 +715,7 @@ class Analyzer:
# Check the test_env passed
test_dir = path.join(
TTPROTO_DIR,
PACKAGE_DIR,
test_env,
TESTCASES_SUBDIR
)
......@@ -743,7 +743,7 @@ class Analyzer:
# Build the search query
search_query = path.join(
TTPROTO_DIR,
PACKAGE_DIR,
self.__test_env,
TESTCASES_SUBDIR,
search
......@@ -772,7 +772,7 @@ class Analyzer:
# Build the module relative name
mod_rel_name = '.'.join([
TTPROTO_DIR,
'ttproto',
self.__test_env,
TESTCASES_SUBDIR,
modname
......@@ -925,7 +925,6 @@ class Analyzer:
with Data.disable_name_resolution():
# Get the capture from the file
capture = Capture(filename)
# Initialize the TC with the list of conversations
test_case = test_case_class(capture)
verdict, rev_frames, log, partial_verdicts, exceptions = test_case.run_test_case()
......
......@@ -56,9 +56,9 @@ from ttproto.core.lib.readers.yaml import YamlReader
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -54,11 +54,10 @@ from ttproto.core.typecheck import *
from ttproto.core.lib.all import *
from ttproto.core.lib.readers.yaml import YamlReader
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -47,6 +47,11 @@ import logging
from collections import OrderedDict
from multiprocessing import Process
# Directories
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
from ttproto import LOG_LEVEL
from ttproto.tat_services import analyze_capture, dissect_capture, get_test_cases, base64_to_pcap_file
......@@ -58,10 +63,6 @@ from ttproto.utils.packet_dumper import launch_amqp_data_to_pcap_dumper, AmqpDat
COMPONENT_ID = NotImplementedError
# Directories
DATADIR = "data" # used mostly as output methods files dir
TMPDIR = "tmp" # used mostly as input methods files dir
LOGDIR = "log"
AUTO_DISSECT_OUTPUT_FILE = os.path.join(DATADIR, 'auto_dissection')
# Prefix and suffix for the hashes
......
......@@ -54,11 +54,10 @@ from ttproto.core.typecheck import typecheck,optional,either,list_of
from ttproto.core.lib.all import *
from ttproto.core.lib.readers.yaml import YamlReader
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -54,11 +54,10 @@ from ttproto.core.typecheck import typecheck,optional,either,list_of
from ttproto.core.lib.all import *
from ttproto.core.lib.readers.yaml import YamlReader
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -54,11 +54,11 @@ from ttproto.core.typecheck import typecheck,optional,either,list_of
from ttproto.core.lib.all import *
from ttproto.core.lib.readers.yaml import YamlReader
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -59,6 +59,10 @@ from ttproto.core.xmlgen import XHTML10Generator, XMLGeneratorControl
from ttproto.core.typecheck import *
from ttproto.core.lib.all import *
# Directories
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# List to generate the changelog page
CHANGELOG = []
......@@ -66,10 +70,6 @@ CHANGELOG_FIRST_COMMIT = "iot2-beta"
# ########################## ttproto API ########################### #
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -17,9 +17,9 @@ from ttproto.utils.pcap_filter import remove_first_frames
ALLOWED_PROTOCOLS_FOR_ANALYSIS = ['coap', '6lowpan', 'onem2m', 'lwm2m']
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......@@ -43,14 +43,13 @@ def analyze_capture(filename, protocol, testcase_id, output_file):
if os.path.isfile(filename) is False and os.path.isfile(os.path.join(TMPDIR, filename)):
filename = os.path.join(TMPDIR, filename)
logger.info("Analyzing PCAP file %s" % filename)
logger.info("Analyzing PCAP file %s, for testcase: %s" % (filename, testcase_id))
if protocol.lower() not in ALLOWED_PROTOCOLS_FOR_ANALYSIS:
raise NotImplementedError('Protocol %s not among the allowed analysis test suites' % protocol)
analysis_results = Analyzer('tat_' + protocol.lower()).analyse(filename, testcase_id)
logger.info('PCAP file analysed: %s' % filename)
logger.info('Analysis result: %s' % str(analysis_results))
logger.info('Analysis finished, result:\n%s' % str(analysis_results))
if output_file and type(output_file) is str:
# save analysis response
......
......@@ -214,7 +214,6 @@ class CoAPTestcase(object):
# end of conversation
self.setverdict(verdict, "expected %s from the %s" % (template, sender))
self.failed_frames.add(self.frame.id)
self.log('ENCONTRE FFAILED FRAME! : ' + self.frame.id)
return False
# check the sender
......@@ -224,14 +223,12 @@ class CoAPTestcase(object):
if verdict is not None:
self.setverdict(verdict, "expected %s from the client" % template)
self.failed_frames.add(self.frame.id)
self.log('ENCONTRE FFAILED FRAME! : ' + self.frame.id)
return False
elif sender == "server":
if src != self.conversation.server:
if verdict is not None:
self.setverdict(verdict, "expected %s from the server" % template)
self.failed_frames.add(self.frame.id)
self.log('ENCONTRE FFAILED FRAME! : ' + self.frame.id)
return False
else:
assert sender is None
......
......@@ -56,6 +56,10 @@ from ttproto.utils import pure_pcapy
from ttproto.core.lib.inet import coap
from ttproto.core.xmlgen import XHTML10Generator, XMLGeneratorControl
# Directories
from ttproto import DATADIR
from ttproto import TMPDIR
from ttproto import LOGDIR
# List to generate the changelog page
CHANGELOG = []
......@@ -63,10 +67,6 @@ CHANGELOG_FIRST_COMMIT = "iot2-beta"
# ########################## ttproto API ########################### #
# Directories
DATADIR = "data"
TMPDIR = "tmp"
LOGDIR = "log"
# Prefix and suffix for the hashes
HASH_PREFIX = 'tt'
......
......@@ -31,6 +31,7 @@
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
from ttproto import TMPDIR
from ttproto.utils.pure_pcapy import *
from ttproto.core.typecheck import *
......@@ -38,8 +39,6 @@ from ttproto.core.typecheck import *
# TODO filter first X layers of pcap
# TODO protocol filter: ex: filter anything that's not IEE802.15.4? dissect() already does this
TMPDIR = "tmp"
# #################### Filter Functions #########################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment