Jack Hansdampf / mbed-mqtt-GSOE1

Dependents:   ESP8266MQTT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TestProcess.cpp Source File

TestProcess.cpp

00001 /**************************************************************************************
00002  * Copyright (c) 2016, Tomoaki Yamaguchi
00003  *
00004  * All rights reserved. This program and the accompanying materials
00005  * are made available under the terms of the Eclipse Public License v1.0
00006  * and Eclipse Distribution License v1.0 which accompany this distribution.
00007  *
00008  * The Eclipse Public License is available at
00009  *    http://www.eclipse.org/legal/epl-v10.html
00010  * and the Eclipse Distribution License is available at
00011  *   http://www.eclipse.org/org/documents/edl-v10.php.
00012  *
00013  * Contributors:
00014  *    Tomoaki Yamaguchi - initial API and implementation 
00015  **************************************************************************************/
00016 
00017 #include <string.h>
00018 #include <cassert>
00019 #include "TestProcess.h"
00020 #include "TestTopics.h"
00021 #include "TestQue.h"
00022 #include "TestTree23.h"
00023 #include "TestTopicIdMap.h"
00024 #include "MQTTSNGWProcess.h"
00025 #include "MQTTSNGWClient.h"
00026 #include "MQTTSNGWPacket.h"
00027 #include "Timer.h"
00028 
00029 using namespace std;
00030 using namespace MQTTSNGW;
00031 
00032 #define ARGV    "./Build/testPFW"
00033 #define CONFDIR "./"
00034 #define CONF    "gateway.conf"
00035 
00036 const char* currentDateTime(void);
00037 
00038 TestProcess::TestProcess()
00039 {
00040     theMultiTaskProcess = this;
00041     theProcess = this;
00042 }
00043 
00044 TestProcess::~TestProcess()
00045 {
00046 
00047 }
00048 
00049 void TestProcess::initialize(int argc, char** argv)
00050 {
00051     MultiTaskProcess::initialize(argc, argv);
00052     assert(0 == strcmp(CONFDIR, getConfigDirName()->c_str()));
00053     assert(0 == strcmp(CONF, getConfigFileName()->c_str()));
00054     resetRingBuffer();
00055 }
00056 
00057 void TestProcess::run(void)
00058 {
00059     char value[256];
00060     int i = 0;
00061     Timer tm;
00062 
00063     /* Test command line parameter */
00064 
00065     assert(1 == getArgc() || 3 == getArgc() );
00066     assert(0 == strcmp(ARGV, *getArgv()));
00067     getParam("BrokerName", value);
00068     assert(0 == strcmp("iot.eclipse.org", value));
00069 
00070     /* Test RingBuffer */
00071     for ( i = 0; i < 1000; i++)
00072     {
00073         putLog("Test RingBuffer %d ", 1234567890);
00074     }
00075     putLog("\n\nRingBuffer Test complieted.\n\n");
00076 
00077     /* Test Timer */
00078     printf("Timer Test start\n");
00079     printf("%s Timer start\n",  currentDateTime());
00080     tm.start(1000);
00081     while (!tm.isTimeup());
00082     printf("%s Timer 1sec\n", currentDateTime());
00083 
00084     tm.start();
00085     while (!tm.isTimeup(1000));
00086     printf("%s Timer 1sec\n", currentDateTime());
00087     printf("Timer Test completed\n\n");
00088 
00089     /* Test Que */
00090     printf("Test  Que            ");
00091     TestQue* tque = new TestQue();
00092     tque->test();
00093     delete tque;
00094 
00095     /* Test Tree23 */
00096     //printf("Test  Tree23         ");
00097     //TestTree23* tree23 = new TestTree23();
00098     //tree23->test();
00099     //delete tree23;
00100 
00101     /* Test TopicTable */
00102     printf("Test  Topic          ");
00103     TestTopics* testTopic = new TestTopics();
00104     testTopic->test();
00105     delete testTopic;
00106 
00107     /* Test TopicIdMap */
00108     printf("Test  TopicIdMap     ");
00109     TestTopicIdMap* testMap = new TestTopicIdMap();
00110     testMap->test();
00111     delete testMap;
00112 
00113     /* Test EventQue */
00114     /*
00115     printf("Test  EventQue       ");
00116     Client* client = new Client();
00117     _evQue.setMaxSize(EVENT_CNT);
00118     for ( int i = 0; i < EVENT_CNT + 4; i++ )
00119     {
00120         Event* ev = new Event();
00121         MQTTSNPacket* packet = new MQTTSNPacket();
00122         packet->setDISCONNECT(i);
00123         ev->setClientSendEvent(client, packet);
00124         _evQue.post(ev);
00125     }
00126     delete client;
00127     */
00128     //MultiTaskProcess::run();
00129 }