summaryrefslogtreecommitdiffstats
path: root/test/vpp_pg_interface.py
AgeCommit message (Expand)AuthorFilesLines
2019-10-11tests: explicitly wait for the PG to finish before looking for capture fileAndrew Yourtchenko1-0/+15
2019-08-20tests: support worker threadsKlement Sekera1-1/+4
2019-07-31tests: disable pg capture before enabling itAndrew Yourtchenko1-1/+2
2019-07-28pg: add GSO supportMohsin Kazmi1-2/+16
2019-06-27tests: rename stream name in testsPaul Vinciguerra1-1/+2
2019-06-04Tests: simple refactor in vpp_pg_interface.Paul Vinciguerra1-25/+23
2019-05-29Tests: vpp_pg_interface. Don't rewrite Dot1AD ethertype.Paul Vinciguerra1-11/+0
2019-05-28make test: add option in pg interfaces for duplicating packetsAlexandre Poirrier1-2/+12
2019-03-11VPP-1508: Use scapy.compat to manage packet level library differences.Paul Vinciguerra1-2/+7
2019-03-11Tests: fix time.sleep(0) # yield. Reduce sleep related log messages.Paul Vinciguerra1-3/+3
2018-06-24Revert "Revert "ipsec: VPP-1316 calculate IP/TCP/UDP inner checksums""Klement Sekera1-3/+3
2018-06-22Revert "ipsec: VPP-1316 calculate IP/TCP/UDP inner checksums"Ole Troan1-3/+3
2018-06-21ipsec: VPP-1316 calculate IP/TCP/UDP inner checksumsKlement Sekera1-3/+3
2017-02-21test: ip6 vrf instances multi-context test (CSIT-497)Jan Gelety1-2/+4
2017-02-14make test: improve stabilityKlement Sekera1-46/+57
2017-02-09make test: work around scapy truncated packetsKlement Sekera1-0/+33
2017-01-12make test: fix capture handling special-caseKlement Sekera1-8/+32
2017-01-11make test: improve documentation and PEP8 complianceKlement Sekera1-22/+26
2017-01-11test: ip4 vrf instances multi-context test (CSIT-492)Jan1-12/+10
2017-01-10IPv6 NS RS tests and fixesNeale Ranns1-2/+3
2017-01-09In python tests send NS packets to the solicited mcast address with correct m...Neale Ranns1-3/+8
2017-01-02make test: fix debug printKlement Sekera1-1/+1
2017-01-02make test: rotate capture files after consuming arp/ndpKlement Sekera1-2/+8
2017-01-02make test: fix assert_nothing_captured apiKlement Sekera1-8/+9
2016-12-23make test: improve handling of packet capturesKlement Sekera1-58/+128
2016-12-19make test: filter IPv6 RAs out by defaultKlement Sekera1-5/+29
2016-12-16make test: improve robustness and performanceKlement Sekera1-23/+59
2016-12-09When waiting for an IPv6 response, filter non-ND packetsNeale Ranns1-16/+21
2016-12-07BFD: basic asynchronous session up/downKlement Sekera1-2/+38
2016-12-05make test: fix missing log/packet messagesKlement Sekera1-20/+26
2016-11-24Remove postinit from make-test interfacesMatej Klotton1-13/+10
2016-11-14make test: improve naming of temporary pcap filesKlement Sekera1-6/+7
2016-11-11Add IRB testMatej Klotton1-1/+90
2016-11-09Improve test framework documentationKlement Sekera1-4/+37
2016-10-26refactor test frameworkKlement Sekera1-0/+99
truct iovec *response = configuration_DispatchCommand( forwarder_GetConfiguration(configFile->forwarder), ((header_control_message *)msg[0].iov_base)->commandID, msg, 0); return response; } /** * Removes leading whitespace (space + tab). * * If the string is all whitespace, the return value will point to the * terminating '\0'. * * @param [in] str A null-terminated c-string * * @retval non-null A pointer in to string of the first non-whitespace * * * Example: * @code * <#example#> * @endcode */ static char *_stripLeadingWhitespace(char *str) { while (isspace(*str)) { str++; } return str; } /** * Removes trailing whitespace * * Inserts a NULL after the last non-whitespace character, modiyfing the input * string. * * @param [in] str A null-terminated c-string * * @return non-null A pointer to the input string * * Example: * @code * { * <#example#> * } * @endcode */ static char *_stripTrailingWhitespace(char *str) { char *p = str + strlen(str) - 1; while (p > str && isspace(*p)) { p--; } // cap it. If no whitespace, p+1 == str + strlen(str), so will overwrite the // current null. If all whitespace p+1 == str+1. For an empty string, p+1 = // str. *(p + 1) = 0; // this does not catch the case where the entire string is whitespace if (p == str && isspace(*p)) { *p = 0; } return str; } /** * Removed leading and trailing whitespace * * Modifies the input string (may add a NULL at the end). Will return * a pointer to the first non-whitespace character or the terminating NULL. * * @param [in] str A null-terminated c-string * * @return non-null A pointer in to the input string * * Example: * @code * { * <#example#> * } * @endcode */ static char *_trim(char *str) { return _stripTrailingWhitespace(_stripLeadingWhitespace(str)); } /** * Parse a string in to a PARCList with one word per element * * The string passed will be modified by inserting NULLs after each token. * * @param [in] str A c-string (will be modified) * * @retval non-null A PARCList where each item is a single word * * Example: * @code * <#example#> * @endcode */ static PARCList *_parseArgs(char *str) { PARCList *list = parcList(parcArrayList_Create(NULL), PARCArrayListAsPARCList); const char delimiters[] = " \t"; char *token; token = strtok(str, delimiters); while (token != NULL) { if (strlen(token) > 0) { parcList_Add(list, strdup(token)); } token = strtok(NULL, delimiters); } // while ((token = strsep(&str, delimiters)) != NULL) { // parcList_Add(list, token); // } return list; } // ============================================================= static void _destroy(ConfigurationFile **configFilePtr) { ConfigurationFile *configFile = *configFilePtr; parcMemory_Deallocate((void **)&configFile->filename); if (configFile->fh != NULL) { fclose(configFile->fh); } controlState_Destroy(&configFile->controlState); } parcObject_ExtendPARCObject(ConfigurationFile, _destroy, NULL, NULL, NULL, NULL, NULL, NULL); parcObject_ImplementRelease(configurationFile, ConfigurationFile); ConfigurationFile *configurationFile_Create(Forwarder *forwarder, const char *filename) { parcAssertNotNull(forwarder, "Parameter hicn-fwd must be non-null"); parcAssertNotNull(filename, "Parameter filename must be non-null"); ConfigurationFile *configFile = parcObject_CreateInstance(ConfigurationFile); if (configFile) { configFile->linesRead = 0; configFile->forwarder = forwarder; configFile->filename = parcMemory_StringDuplicate(filename, strlen(filename)); parcAssertNotNull(configFile->filename, "Could not copy string '%s'", filename); // setup the control state for the command parser: last parameter NULL // because // writeRead still not implemented from configuration file. configFile->controlState = controlState_Create(configFile, _writeRead, false); // we do not register Help commands controlState_RegisterCommand(configFile->controlState, controlRoot_Create(configFile->controlState)); // open the file and make sure we can read it configFile->fh = fopen(configFile->filename, "r"); if (configFile->fh) { if (logger_IsLoggable(forwarder_GetLogger(forwarder), LoggerFacility_Config, PARCLogLevel_Debug)) { logger_Log(forwarder_GetLogger(forwarder), LoggerFacility_Config, PARCLogLevel_Debug, __func__, "Open config file %s", configFile->filename); } } else { if (logger_IsLoggable(forwarder_GetLogger(forwarder), LoggerFacility_Config, PARCLogLevel_Error)) { logger_Log(forwarder_GetLogger(forwarder), LoggerFacility_Config, PARCLogLevel_Error, __func__, "Could not open config file %s: (%d) %s", configFile->filename, errno, strerror(errno)); } // failure cleanup the object -- this nulls it so final return null be // NULL configurationFile_Release(&configFile); } } return configFile; } bool configurationFile_Process(ConfigurationFile *configFile) { parcAssertNotNull(configFile, "Parameter configFile must be non-null"); // default to a "true" return value and only set to false if we encounter an // error. bool success = true; #define BUFFERLEN 2048 char buffer[BUFFERLEN]; configFile->linesRead = 0; // always clear errors and fseek to start of file in case we get called // multiple times. clearerr(configFile->fh); rewind(configFile->fh); while (success && fgets(buffer, BUFFERLEN, configFile->fh) != NULL) { configFile->linesRead++; char *stripedBuffer = _trim(buffer); if (strlen(stripedBuffer) > 0) { if (stripedBuffer[0] != '#') { // not empty and not a comment // _parseArgs will modify the string char *copy = parcMemory_StringDuplicate(stripedBuffer, strlen(stripedBuffer)); PARCList *args = _parseArgs(copy); CommandReturn result = controlState_DispatchCommand(configFile->controlState, args); // we ignore EXIT from the configuration file if (result == CommandReturn_Failure) { if (logger_IsLoggable(forwarder_GetLogger(configFile->forwarder), LoggerFacility_Config, PARCLogLevel_Error)) { logger_Log(forwarder_GetLogger(configFile->forwarder), LoggerFacility_Config, PARCLogLevel_Error, __func__, "Error on input file %s line %d: %s", configFile->filename, configFile->linesRead, stripedBuffer); } success = false; } parcList_Release(&args); parcMemory_Deallocate((void **)&copy); } } } if (ferror(configFile->fh)) { if (logger_IsLoggable(forwarder_GetLogger(configFile->forwarder), LoggerFacility_Config, PARCLogLevel_Error)) { logger_Log(forwarder_GetLogger(configFile->forwarder), LoggerFacility_Config, PARCLogLevel_Error, __func__, "Error on input file %s line %d: (%d) %s", configFile->filename, configFile->linesRead, errno, strerror(errno)); } success = false; } return success; }