-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemperatureshow.cpp
More file actions
42 lines (39 loc) · 921 Bytes
/
temperatureshow.cpp
File metadata and controls
42 lines (39 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
using namespace std;
#include<gtest/gtest.h>
TEST(TEMPERATURESHOW,temperatureshow1)
{
char rbuf[4096];
char cbuf[1024];
memset(rbuf,0,4096);
sprintf(cbuf,"bcmcmd 'show temp'|grep 'average current temperature is'");
FILE *stream = popen(cbuf,"r");
memset(rbuf,0,4096);
fread(rbuf,sizeof(char),sizeof(rbuf),stream);
printf("%s",rbuf);
#if 0
char mac[128];
sprintf(mac,"%s",rbuf);
//printf("%s",mac);
sprintf(cbuf,"show mac");
stream = popen(cbuf,"r");
memset(rbuf,0,4096);
fread(rbuf,sizeof(char),sizeof(rbuf),stream);
char *p = strstr(rbuf,mac);
printf("1:%s:",rbuf);
if(p == NULL){
ASSERT_FALSE(1==1);
}
#endif
}