31 bool SmokeTest::dashPauseState =
false;
32 bool SmokeTest::dashFastForwardState =
false;
33 bool SmokeTest::dashPlayState =
false;
34 bool SmokeTest::dashRewindState =
false;
35 bool SmokeTest::hlsPauseState =
false;
36 bool SmokeTest::hlsFastForwardState =
false;
37 bool SmokeTest::hlsPlayState =
false;
38 bool SmokeTest::hlsRewindState =
false;
39 bool SmokeTest::livePlayState =
false;
40 bool SmokeTest::livePauseState =
false;
42 std::vector<std::string> SmokeTest::dashTuneData(0);
43 std::vector<std::string> SmokeTest::hlsTuneData(0);
44 std::vector<std::string> SmokeTest::liveTuneData(0);
46 std::map<std::string, std::string> SmokeTest::smokeTestUrls = std::map<std::string, std::string>();
48 bool SmokeTest::aampTune()
58 void SmokeTest::loadSmokeTestUrls()
61 const std::string smokeurlFile(
"/smoketest.csv");
62 int BUFFER_SIZE = 500;
63 char buffer[BUFFER_SIZE];
66 if ( (fp = mAampPlayer.getConfigFile(smokeurlFile)) != NULL)
68 printf(
"%s:%d: opened smoketest file\n",__FUNCTION__,__LINE__);
72 if(fgets(buffer, BUFFER_SIZE, fp) != NULL)
74 buffer[strcspn(buffer,
"\n")] = 0;
75 std::string urlData(buffer);
77 std::size_t delimiterPos = urlData.find(
",");
79 if(delimiterPos != std::string::npos)
81 smokeTestUrls[ urlData.substr(0, delimiterPos) ] = urlData.substr(delimiterPos + 1);
91 void SmokeTest::vodTune(
const char *stream)
93 const char *url = NULL;
95 std::string testFilePath;
97 time_t initialTime = 0, currentTime = 0;
98 std::map<std::string, std::string>::iterator itr;
100 createTestFilePath(testFilePath);
101 if(strncmp(stream,
"Dash",4) == 0)
103 fileName = testFilePath +
"tuneDashStream.txt";
104 itr = smokeTestUrls.find(
"VOD_DASH");
106 if(itr != smokeTestUrls.end())
108 url = (itr->second).c_str();
113 url =
"https://cpetestutility.stb.r53.xcal.tv/VideoTestStream/main.mpd";
117 else if(strncmp(stream,
"Hls",3) == 0)
119 fileName = testFilePath +
"tuneHlsStream.txt";
120 itr = smokeTestUrls.find(
"VOD_HLS");
122 if(itr != smokeTestUrls.end())
124 url = (itr->second).c_str();
129 url =
"https://cpetestutility.stb.r53.xcal.tv/VideoTestStream/main.m3u8";
134 stdout = fopen(fileName.c_str(),
"w");
136 mAampPlayer.mPlayerInstanceAamp->
Tune(url);
138 initialTime = time(NULL);
145 printf(
"%s:%d: Tune sub task started\n",__FUNCTION__,__LINE__);
146 mAampPlayer.mPlayerInstanceAamp->
Tune(url);
147 mAampPlayer.mPlayerInstanceAamp->
SetRate(0);
148 mAampPlayer.mPlayerInstanceAamp->
SetRate(4);
149 mAampPlayer.mPlayerInstanceAamp->
SetRate(1);
151 mAampPlayer.mPlayerInstanceAamp->
SetRate(-2);
153 mAampPlayer.mPlayerInstanceAamp->
Stop();
156 printf(
"%s:%d: Tune %s completed\n",__FUNCTION__,__LINE__,stream);
160 currentTime = time(NULL);
161 if((currentTime - initialTime) > 1200)
171 void SmokeTest::liveTune(
const char *stream)
173 const char *url = NULL;
174 std::string fileName;
175 std::string testFilePath;
178 createTestFilePath(testFilePath);
180 url =
"https://ll-usw2.akamaized.net/live/disk/sky/DASH-LL-sky.toml/sky.mpd";
181 fileName = testFilePath +
"tuneLive.txt";
184 stdout = fopen(fileName.c_str(),
"w");
186 mAampPlayer.mPlayerInstanceAamp->
Tune(url);
188 mAampPlayer.mPlayerInstanceAamp->
SetRate(0);
189 mAampPlayer.mPlayerInstanceAamp->
SetRate(1);
191 mAampPlayer.mPlayerInstanceAamp->
Stop();
199 bool SmokeTest::createTestFilePath(std::string &filePath)
201 getFilePath(filePath);
202 DIR *dir = opendir(filePath.c_str());
205 mkdir(filePath.c_str(), 0777);
215 void SmokeTest::getTuneDetails()
219 readLiveData(
"Live");
222 bool SmokeTest::getFilePath(std::string &filePath)
224 #ifdef SIMULATOR_BUILD
225 char *ptr = getenv(
"HOME");
228 filePath.append(ptr);
229 filePath +=
"/smoketest/";
233 printf(
"%s:%d: Path not found \n",__FUNCTION__,__LINE__);
237 filePath =
"/opt/smoketest/";
242 bool SmokeTest::readVodData(
const char *stream)
244 int BUFFER_SIZE = 500;
245 char buffer[BUFFER_SIZE];
248 std::string fileName;
250 if(getFilePath(fileName))
252 if(strncmp(stream,
"Dash",4) == 0)
253 fileName = fileName +
"tuneDashStream.txt";
254 else if(strncmp(stream,
"Hls",3) == 0)
255 fileName = fileName +
"tuneHlsStream.txt";
257 if( fp = fopen(fileName.c_str(),
"r"))
261 if(fgets(buffer, BUFFER_SIZE, fp) != NULL)
264 if (strstr(buffer,
"IP_AAMP_TUNETIME:") != NULL)
266 token = strstr(buffer,
"IP_AAMP_TUNETIME:");
267 token[strcspn(token,
"\n")] = 0;
269 std::stringstream ss(token+17);
272 while(std::getline(ss, data,
','))
274 if(strncmp(stream,
"Dash",4) == 0)
276 SmokeTest::dashTuneData.push_back(data);
279 else if(strncmp(stream,
"Hls",3) == 0)
281 SmokeTest::hlsTuneData.push_back(data);
287 if (strstr(buffer,
"AAMP_EVENT_STATE_CHANGED: PAUSED (6)") != NULL)
289 if(strncmp(stream,
"Dash",4) == 0)
290 dashPauseState =
true;
291 else if(strncmp(stream,
"Hls",3) == 0)
292 hlsPauseState =
true;
295 if (strstr(buffer,
"AAMP_EVENT_SPEED_CHANGED current rate=4") != NULL)
297 if(strncmp(stream,
"Dash",4) == 0)
298 dashFastForwardState =
true;
299 else if(strncmp(stream,
"Hls",3) == 0)
300 hlsFastForwardState =
true;
303 if (strstr(buffer,
"AAMP_EVENT_SPEED_CHANGED current rate=1") != NULL)
305 if(strncmp(stream,
"Dash",4) == 0)
306 dashPlayState =
true;
307 else if(strncmp(stream,
"Hls",3) == 0)
311 if (strstr(buffer,
"AAMP_EVENT_SPEED_CHANGED current rate=-2") != NULL)
313 if(strncmp(stream,
"Dash",4) == 0)
314 dashRewindState =
true;
315 else if(strncmp(stream,
"Hls",3) == 0)
316 hlsRewindState =
true;
329 printf(
"%s:%d: %s file not found \n",__FUNCTION__,__LINE__,stream);
336 bool SmokeTest::readLiveData(
const char *stream)
338 int BUFFER_SIZE = 500;
339 char buffer[BUFFER_SIZE];
342 std::string fileName;
344 if(getFilePath(fileName))
346 fileName = fileName +
"tuneLive.txt";
348 if(fp = fopen(fileName.c_str(),
"r"))
352 if(fgets(buffer, BUFFER_SIZE, fp) != NULL)
354 if (strstr(buffer,
"IP_TUNETIME:") != NULL)
356 token = strstr(buffer,
"IP_TUNETIME:");
357 token[strcspn(token,
"\n")] = 0;
359 std::stringstream ss(token+12);
362 while(std::getline(ss, data,
','))
364 SmokeTest::liveTuneData.push_back(data);
369 if (strstr(buffer,
"AAMP_EVENT_STATE_CHANGED: PAUSED (6)") != NULL)
371 livePauseState =
true;
374 if (strstr(buffer,
"AAMP_EVENT_SPEED_CHANGED current rate=1") != NULL)
376 livePlayState =
true;
386 printf(
"%s:%d: %s file not found \n",__FUNCTION__,__LINE__,stream);
394 TEST(dashTuneTest, ManifestDLStartTime)
396 if(!SmokeTest::dashTuneData.empty())
397 EXPECT_LE(stoi(SmokeTest::dashTuneData[3]),7);
401 TEST(dashTuneTest, ManifestDLEndTime)
403 if(!SmokeTest::dashTuneData.empty())
404 EXPECT_LE(stoi(SmokeTest::dashTuneData[4]),1000);
408 TEST(dashTuneTest, ManifestDLFailCount)
410 if(!SmokeTest::dashTuneData.empty())
411 EXPECT_EQ(stoi(SmokeTest::dashTuneData[5]),0);
415 TEST(dashTuneTest, VideoPlaylistDLFailCount)
417 if(!SmokeTest::dashTuneData.empty())
418 EXPECT_EQ(stoi(SmokeTest::dashTuneData[8]),0);
422 TEST(dashTuneTest, AudioPlaylistDLFailCount)
424 if(!SmokeTest::dashTuneData.empty())
425 EXPECT_EQ(stoi(SmokeTest::dashTuneData[11]),0);
429 TEST(dashTuneTest, VideoInitDLFailCount)
431 if(!SmokeTest::dashTuneData.empty())
432 EXPECT_EQ(stoi(SmokeTest::dashTuneData[14]),0);
436 TEST(dashTuneTest, AudioInitDLFailCount)
438 if(!SmokeTest::dashTuneData.empty())
439 EXPECT_EQ(stoi(SmokeTest::dashTuneData[17]),0);
443 TEST(dashTuneTest, VideoFragmentDLFailCount)
445 if(!SmokeTest::dashTuneData.empty())
446 EXPECT_EQ(stoi(SmokeTest::dashTuneData[20]),0);
450 TEST(dashTuneTest, AudioFragmentDLFailCount)
452 if(!SmokeTest::dashTuneData.empty())
453 EXPECT_EQ(stoi(SmokeTest::dashTuneData[24]),0);
457 TEST(dashTuneTest, DrmFailErrorCode)
459 if(!SmokeTest::dashTuneData.empty())
460 EXPECT_EQ(stoi(SmokeTest::dashTuneData[28]),0);
464 TEST(dashTuneTest, PauseState)
466 EXPECT_EQ(SmokeTest::dashPauseState,
true);
470 TEST(dashTuneTest, FastForwardState)
472 EXPECT_EQ(SmokeTest::dashFastForwardState,
true);
476 TEST(dashTuneTest, PlayState)
478 EXPECT_EQ(SmokeTest::dashPlayState,
true);
482 TEST(dashTuneTest, RewindState)
484 EXPECT_EQ(SmokeTest::dashRewindState,
true);
488 TEST(hlsTuneTest, ManifestDLStartTime)
490 if(!SmokeTest::hlsTuneData.empty())
491 EXPECT_LE(stoi(SmokeTest::hlsTuneData[3]),7);
495 TEST(hlsTuneTest, ManifestDLEndTime)
497 if(!SmokeTest::hlsTuneData.empty())
498 EXPECT_LE(stoi(SmokeTest::hlsTuneData[4]),1000);
502 TEST(hlsTuneTest, ManifestDLFailCount)
504 if(!SmokeTest::hlsTuneData.empty())
505 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[5]),0);
509 TEST(hlsTuneTest, VideoPlaylistDLFailCount)
511 if(!SmokeTest::hlsTuneData.empty())
512 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[8]),0);
516 TEST(hlsTuneTest, AudioPlaylistDLFailCount)
518 if(!SmokeTest::hlsTuneData.empty())
519 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[11]),0);
523 TEST(hlsTuneTest, VideoInitDLFailCount)
525 if(!SmokeTest::hlsTuneData.empty())
526 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[14]),0);
530 TEST(hlsTuneTest, AudioInitDLFailCount)
532 if(!SmokeTest::hlsTuneData.empty())
533 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[17]),0);
537 TEST(hlsTuneTest, VideoFragmentDLFailCount)
539 if(!SmokeTest::hlsTuneData.empty())
540 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[20]),0);
544 TEST(hlsTuneTest, AudioFragmentDLFailCount)
546 if(!SmokeTest::hlsTuneData.empty())
547 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[24]),0);
551 TEST(hlsTuneTest, DrmFailErrorCode)
553 if(!SmokeTest::hlsTuneData.empty())
554 EXPECT_EQ(stoi(SmokeTest::hlsTuneData[28]),0);
558 TEST(hlsTuneTest, PauseState)
560 EXPECT_EQ(SmokeTest::hlsPauseState,
true);
564 TEST(hlsTuneTest, FastForwardState)
566 EXPECT_EQ(SmokeTest::hlsFastForwardState,
true);
570 TEST(hlsTuneTest, PlayState)
572 EXPECT_EQ(SmokeTest::hlsPlayState,
true);
576 TEST(hlsTuneTest, RewindState)
578 EXPECT_EQ(SmokeTest::hlsRewindState,
true);
582 TEST(liveTuneTest, PauseState)
584 EXPECT_EQ(SmokeTest::livePauseState,
true);
588 TEST(liveTuneTest, PlayState)
590 EXPECT_EQ(SmokeTest::livePlayState,
true);