From 4996b6fa2216122cb8310b12f931b4a4114eb1f5 Mon Sep 17 00:00:00 2001 From: WJ Date: Wed, 18 Oct 2023 11:08:09 +0800 Subject: [PATCH 1/2] add 1801GN.c --- Network/README | 4 ++- Network/gjb_S0101801GN.c | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 Network/gjb_S0101801GN.c diff --git a/Network/README b/Network/README index 35dd104..76bc247 100644 --- a/Network/README +++ b/Network/README @@ -1 +1,3 @@ -###网络管理 \ No newline at end of file +###网络管理 + +需要切换到root执行:sudo su \ No newline at end of file diff --git a/Network/gjb_S0101801GN.c b/Network/gjb_S0101801GN.c new file mode 100644 index 0000000..1ecbbfa --- /dev/null +++ b/Network/gjb_S0101801GN.c @@ -0,0 +1,73 @@ +/********************************************************************************************************* +** +** GJB ��׼���Լ� +** +** Copyright All Rights Reserved +** +**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +** +** �� �� ��: gjb_S0101801GN.c +** +** �ļ���������: 2021 �� 1 �� 12 �� +** +** �� ��: �����豸�������ܲ��ԡ����Ʋ����������룬ʵ�ֶ����� +** �豸�����ú͹���������������IP��ַ���������롢���ء� +** +** ͬʱ����ʹ�������޸�IP��ַ, ����, ����: +** ifconfig eth0 192.168.1.110 netmask 255.255.255.0 gateway 192.168.1.1 +*********************************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//int argc, char *argv[] +int main() +{ + int fd = 0; + struct ifreq ifr = {0}; + struct ifconf ifc = {0}; + int ret = 0; + int i; + uint8_t ip[4] = {192,168,8,1}; + + memset(&ifr, 0, sizeof(ifr)); + // ifr.ifr_addr.sa_family = AF_INET; + strncpy(ifr.ifr_name, "ens33", IFNAMSIZ); /* �������� */ + + /* ����socket������ */ + fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); + if (fd <= 0) + { + printf("create socket fd failed,%s\n", strerror(errno)); + return -1; + } + + //����IP���� + ifr.ifr_addr.sa_family = AF_INET; + struct sockaddr_in *addr = (struct sockaddr_in *)&(ifr.ifr_addr); + memcpy(&(addr->sin_addr.s_addr), ip, 4); + + ret = ioctl(fd, SIOCSIFADDR, &ifr); + if (ret < 0) + { + printf("ioctl failed,%s\n", strerror(errno)); + goto __exit; + } + +__exit: + if (fd != 0) + { + close(fd); + } + return ret; +} + -- Gitee From a9305a53abb7eb27c5b2a78cbeae82c9259171d0 Mon Sep 17 00:00:00 2001 From: WJ Date: Mon, 6 Nov 2023 20:46:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E5=92=8C=E5=AE=89?= =?UTF-8?q?=E5=85=A8=EF=BC=8C=E9=83=A8=E5=88=86=E6=9C=AA=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Network/README | 11 +- Network/gjb_S0101801GN.c | 14 +- Network/gjb_S0101802GN.c | 319 ++++++++++ Network/gjb_S0101803GN_1.c | 171 ++++++ Network/gjb_S0101803GN_2.c | 84 +++ Network/gjb_S0101803GN_3.c | 80 +++ Network/gjb_S0101803GN_4.c | 76 +++ Network/gjb_S0101803GN_5.c | 77 +++ Network/gjb_S0101804GN_3.c | 70 +++ Network/gjb_S0101804GN_4.c | 173 ++++++ Network/gjb_S0101804GN_5.c | 103 ++++ security/README | 6 +- security/gjb_S0101611AQ.c | 369 ++++++++++++ security/gjb_S0102601AQ_deadlock.c | 214 +++++++ security/gjb_S0102602AQ.c | 255 ++++++++ security/gjb_S0102603AQ.c | 744 ++++++++++++++++++++++++ security/gjb_S0102605AQ.c | 128 ++++ security/gjb_S0102606AQ_addr_nonalign.c | 120 ++++ security/gjb_S0102606AQ_addr_overflow.c | 115 ++++ security/gjb_S0102606AQ_illgel_code.c | 114 ++++ 20 files changed, 3234 insertions(+), 9 deletions(-) create mode 100644 Network/gjb_S0101802GN.c create mode 100644 Network/gjb_S0101803GN_1.c create mode 100644 Network/gjb_S0101803GN_2.c create mode 100644 Network/gjb_S0101803GN_3.c create mode 100644 Network/gjb_S0101803GN_4.c create mode 100644 Network/gjb_S0101803GN_5.c create mode 100644 Network/gjb_S0101804GN_3.c create mode 100644 Network/gjb_S0101804GN_4.c create mode 100644 Network/gjb_S0101804GN_5.c create mode 100644 security/gjb_S0101611AQ.c create mode 100644 security/gjb_S0102601AQ_deadlock.c create mode 100644 security/gjb_S0102602AQ.c create mode 100644 security/gjb_S0102603AQ.c create mode 100644 security/gjb_S0102605AQ.c create mode 100644 security/gjb_S0102606AQ_addr_nonalign.c create mode 100644 security/gjb_S0102606AQ_addr_overflow.c create mode 100644 security/gjb_S0102606AQ_illgel_code.c diff --git a/Network/README b/Network/README index 76bc247..f68a27f 100644 --- a/Network/README +++ b/Network/README @@ -1,3 +1,12 @@ ###网络管理 -需要切换到root执行:sudo su \ No newline at end of file +## 1.需要切换到root执行:sudo su +## 2.pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。 gcc gjb_S0101802GN.c -o 1802GN -lpthread +## 3.1 需要切换到root执行:sudo su +## 3.2 程序可正常运行,抓包工具找不到IP包 +## 3.3 程序可正常运行,抓包工具抓的为ICMPV6包 +## 3.4 程序可正常运行,出现TCP建立连接包 +## 3.5 程序可正常运行,无UDP包 +## 4.1,4.2功能实现不确定 +## 4.3 应该正常 +## 4.4 暂时缺少服务端。 \ No newline at end of file diff --git a/Network/gjb_S0101801GN.c b/Network/gjb_S0101801GN.c index 1ecbbfa..e1425e9 100644 --- a/Network/gjb_S0101801GN.c +++ b/Network/gjb_S0101801GN.c @@ -1,19 +1,19 @@ /********************************************************************************************************* ** -** GJB ��׼���Լ� +** GJB 标准测试集 ** ** Copyright All Rights Reserved ** -**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +**--------------文件信息-------------------------------------------------------------------------------- ** -** �� �� ��: gjb_S0101801GN.c +** 文 件 名: gjb_S0101801GN.c ** -** �ļ���������: 2021 �� 1 �� 12 �� +** 文件创建日期: 2021 年 1 月 12 日 ** -** �� ��: �����豸�������ܲ��ԡ����Ʋ����������룬ʵ�ֶ����� -** �豸�����ú͹���������������IP��ַ���������롢���ء� +** 描 述: 网络设备管理功能测试。编制测试用例代码,实现对网络 +** 设备的配置和管理,尤其是设置IP地址、子网掩码、网关。 ** -** ͬʱ����ʹ�������޸�IP��ַ, ����, ����: +** 同时可以使用命令修改IP地址, 掩码, 网关: ** ifconfig eth0 192.168.1.110 netmask 255.255.255.0 gateway 192.168.1.1 *********************************************************************************************************/ diff --git a/Network/gjb_S0101802GN.c b/Network/gjb_S0101802GN.c new file mode 100644 index 0000000..0392c16 --- /dev/null +++ b/Network/gjb_S0101802GN.c @@ -0,0 +1,319 @@ +/********************************************************************************************************* +** +** GJB ׼Լ +** +** Copyright All Rights Reserved +** +**--------------ļϢ-------------------------------------------------------------------------------- +** +** : gjb_S0101802GN.c +** +** ļ: 2021 1 12 +** +** : ׼׽ֱ̽ӿڹܲԡñ׼׽ֽӿڱд +** ͻͷʵ繦ܡ +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef TEST_IP +#define TEST_IP "192.168.6.128" +#endif + +#define IP_ADDR TEST_IP + +void server_test() +{ + int s,on = 1; + int ret1 = -2; + int ret2 = -2; + + int newSock; + struct sockaddr_in addr; + int addrLen; + + int ret3 = -2; + int ret4 = -2; + int ret5 = -2; + int ret6 = -2; + + char recvbuf[1024] = {0}; + int buf_len = sizeof(recvbuf); + char sendbuf[] = "This is a message from 192.168.1.110"; + int buf_len1 = sizeof(sendbuf); + struct sockaddr_in srvr; + + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (s == -1) { + printf("socket error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "socket error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("socket success!\n"); + // GJB_PRT_INFO( "socket success!\n"); + } + + /* + * socket ѡ SO_REUSEADDR + ˿ڸüsetsockopt + */ + ret1 = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)); + if(ret1 == -1) { + printf("setsockopt error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "setsockopt error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("setsockopt success!\n"); + // GJB_PRT_INFO( "setsockopt success!\n"); + } + + int size = sizeof(on); + ret6 = getsockopt( s, SOL_SOCKET, SO_REUSEADDR, + (char *)&on, (socklen_t *)&size); + if(ret6 == -1) { + printf("getsockopt error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "getsockopt error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("getsockopt success!\n"); + // GJB_PRT_INFO( "getsockopt success!\n"); + } + + memset(&srvr, 0, sizeof(srvr)); +/* +struct sockaddr_in { + short sa_family;//ַ壬2ֽ + unsigned short int sin_port;//˿ںţ2ֽ + struct in_addr sin_addr;//IPַ4ֽ + unsigned char sin_zero[];//0Աstruct sockaddrͬС8ֽ +} +*/ + srvr.sin_family = AF_INET; + srvr.sin_port = htons(8081); + srvr.sin_addr.s_addr = inet_addr(IP_ADDR); + + ret2 = bind(s, (struct sockaddr *)&srvr, sizeof(srvr)); + if (ret2 == -1) { + printf("bind error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "bind error!\n"); + // return (GJB_PRI_FAIL()); + + } else { + printf("bind success!\n"); + // GJB_PRT_INFO( "bind success!\n"); + } + + /* + * socket + */ + ret3 = listen(s, 10); + if (ret3 == -1) { + printf("listen error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "listen error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("listen success!\n"); + // GJB_PRT_INFO( "listen success!\n"); + } + + memset(&addr, 0, sizeof(addr)); + addrLen = sizeof (struct sockaddr); + + newSock = accept(s, (struct sockaddr *)&addr, (socklen_t *)&addrLen); + if (newSock == -1) { + printf("accept error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "accept error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("accept success!\n"); + // GJB_PRT_INFO( "accept success!\n"); + } + + ret4 = recv(newSock, recvbuf, buf_len, 0); + if(ret4 == -1) { + printf("recv error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "recv error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("recv success!\n"); + // GJB_PRT_INFO( "recv success!\n"); + } + + ret5 = send(newSock, sendbuf, buf_len1, 0); + if (ret5 == -1) { + printf("send error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "send error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("send success!\n"); + // GJB_PRT_INFO( "send success!\n"); + } + + close(newSock); + close(s); + + // return 0; +} + +void client_test() +{ + int s; + int ret1 = -2; + int ret2 = -2; + + int newSock; + struct sockaddr_in addr; + int addrLen; + + char sendbuf[] = "This is a message from 192.168.1.88"; + int buf_len1 = sizeof(sendbuf); + struct sockaddr_in srvr; + + /* + * socket TCP + */ + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (s == -1) { + printf("child socket error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "child socket error!\n"); + // return (GJB_PRI_FAIL()); + + } else { + printf("child socket success!\n"); + // GJB_PRT_INFO( "child socket success!\n"); + } + + memset(&srvr, 0, sizeof(srvr)); + + srvr.sin_family = AF_INET; + srvr.sin_port = htons(8080); + srvr.sin_addr.s_addr = inet_addr(IP_ADDR); + + /* + * IP ַ IP_ADDR ˿ 8080 + */ + ret2 = bind(s, (struct sockaddr *)&srvr, sizeof(srvr)); + if (ret2 == -1) { + printf("child bind error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "child bind error = %d!\n", errno); + // return (GJB_PRI_FAIL()); + + } else { + printf("child bind success!\n"); + // GJB_PRT_INFO( "child bind success!\n"); + } + + memset(&addr, 0, sizeof(addr)); + addr.sin_family = AF_INET; + addr.sin_port = htons(8081); + addr.sin_addr.s_addr = inet_addr(IP_ADDR); + addrLen = sizeof (addr); + + /* + * Ӹʱ֤Ѿ accept. + */ + sleep(1); + + /* + * IP_ADDR ˿ 8081 + */ + newSock = connect(s, (struct sockaddr *)&addr, addrLen); + if (newSock == -1) { + printf("child connect error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "child connect error!\n"); + // return (GJB_PRI_FAIL()); + + } else { + printf("child connect success!\n"); + // GJB_PRT_INFO( "child connect success!\n"); + } + + /* + * + */ + ret1 = send(s, sendbuf, buf_len1, 0); + if(ret1 == -1) { + printf("child send error!\n"); + // return -1; + // GJB_PRT_ERROR_INFO( "child send error!\n"); + // return (GJB_PRI_FAIL()); + } else { + printf("child send success!\n"); + // GJB_PRT_INFO( "child send success!\n"); + } + + close(newSock); + close(s); + // return 0; +} + +int main() +{ + pthread_t tid, tid1; + int ret; + void *retval1; + void *retval2; + + ret = pthread_create(&tid, NULL, (void *)server_test, NULL); + if (ret != 0) { + printf("server_test create failed!\n"); + return -1; + // GJB_PRT_ERROR_INFO( "server_test create failed!\n"); + // return (GJB_PRI_FAIL()); + } + + ret = pthread_create(&tid1, NULL, (void *)client_test, NULL); + if (ret != 0) { + printf("client_test create failed!\n"); + return -1; + // GJB_PRT_ERROR_INFO( "client_test create failed!\n"); + // return (GJB_PRI_FAIL()); + } + + ret = pthread_join(tid, &retval1); + if (ret != 0) { + printf("pthread join server_test failed!\n"); + return -1; + // GJB_PRT_ERROR_INFO( "pthread join server_test failed!\n"); + // return (GJB_PRI_FAIL()); + } + + ret = pthread_join(tid1, &retval2); + if (ret != 0) { + printf("pthread join client_test failed!\n"); + return -1; + // GJB_PRT_ERROR_INFO( "pthread join client_test failed!\n"); + // return (GJB_PRI_FAIL()); + } + + if (((long)retval1 == 0) && ((long)retval2 == 0)) { + return 0; + // return (GJB_PRI_PASS()); + } else { + return -1; + // return (GJB_PRI_FAIL()); + } +} diff --git a/Network/gjb_S0101803GN_1.c b/Network/gjb_S0101803GN_1.c new file mode 100644 index 0000000..97efaf1 --- /dev/null +++ b/Network/gjb_S0101803GN_1.c @@ -0,0 +1,171 @@ +/********************************************************************************************************* +** +** GJB 标准测试集 +** +** Copyright All Rights Reserved +** +**--------------文件信息-------------------------------------------------------------------------------- +** +** 文 件 名: gjb_S0101803GN_6.c +** +** 文件创建日期: 2021 年 1 月 12 日 +** +** 描 述: 基本网络协议支持功能测试。编制测试用例代码,通过调 +** 用TCP、UDP、IP、ICMP和ARP协议接口,验证各项协议正 +** 确性,同时利用网络协议分析工具,分析网络包的正确性。 +** ARP +** +** !!!!使用 wireshark 抓包工具进行分析查看 +*********************************************************************************************************/ + + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#define IPV4_LENGTH 4 +#define Dev "ens33" //网卡名 +#define buffer_len 60 //ARP请求包大小为60B,,抓包时会抓到一些42B的包,这是抓包软件没有显示18B的Padding字段,Padding全0填充在包的末尾 +unsigned char sender_ip[4] = {192,168,6,128}; //ARP请求的源IP +unsigned char target_ip[4] = {192,168,6,1}; //ARP请求的目标IP +/*ARP包结构*/ +/*字段顺序不可更改,发包时是直接将buffer发出*/ +struct arp_head +{ + unsigned short hardware_type; //硬件类型#1:Ethernet + unsigned short protocol_type; //协议类型#0x0800:IPv4 + unsigned char hardware_size; //MAC地址长度#6 + unsigned char protocol_size; //IP地址长度#4 + unsigned short opcode; //ARP类型#1:request;2:reply + unsigned char sender_mac[ETH_ALEN]; //源MAC地址 + unsigned char sender_ip[IPV4_LENGTH]; //源IP地址 + unsigned char target_mac[ETH_ALEN]; //目标MAC地址 + unsigned char target_ip[IPV4_LENGTH]; //目标IP地址 +}; + +int main() +{ + //创建buffer + unsigned char buffer[buffer_len]; + memset(buffer, 0, buffer_len); + //创建以太网头部指针,指向buffer + struct ethhdr *eth_req = (struct ethhdr*)buffer; + //创建ARP包指针,指向buffer的后46字节,因为以太网头包含:2*6B(MAC地址)+2B(协议地址)=14B + struct arp_head *arp_req = (struct arp_head*)(buffer+14); + //创建sockaddr_ll结构地址 + struct sockaddr_ll sock_addr; + //创建socket + /***int socket(int __domain, int __type, int __protocol) + *** __domain + * PF_PACKET指示为二层协议簇 + * 使用AF_PACKET也可,socket.h中有#define AF_PACKET PF_PACKET + *** __type + * 使用PF_PACKET的后,__type只能选择SOCK_RAW或者SOCK_DGRAM + * 其中SOCK_RAW可以自己构造帧头,SOCK_DGRAM不行 + * 帧头使用sockaddr_ll结构体构建,这个结构体在if_packet.h中 + * 有一些资料这里选择的是SOCK_PACKET,这个类型目前已经被建议弃用 + *** __protocol + * ETH_P_ARP意味着我们仅仅接受ARP类型 + * 如果是ETH_P_ALL就意味着我们接受所有类型帧 + * 更多选项参看if_ether.h中定义 + */ + int sock_fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ARP)); + if(sock_fd == -1){ + perror("socket()"); + exit(-1); + } + /**获取网卡等需要的信息 + * ifreq结构体可以用于设置或者获取网卡等相关信息,定义在if.h中 + * 配合ioctl()一起使用 + * ioctl()的具体参数用法和系统实现相关,不是通用的,具体参见ioctls.h + * 以下获取的信息都会保存在ifreq不同字段之中 + */ + struct ifreq ifr; + + /*根据网卡设备名获取Index*/ + strcpy(ifr.ifr_name, Dev); + if(ioctl(sock_fd, SIOCGIFINDEX, &ifr) == -1) + { + perror("SIOCGIFINDEX"); + exit(-1); + } + int ifindex = ifr.ifr_ifindex; + printf("网卡索引为:%d\n",ifindex); + + /*获取网卡设备MAC地址*/ + if(ioctl(sock_fd, SIOCGIFHWADDR, &ifr) == -1) + { + perror("SIOCGIFHWADDR"); + exit(-1); + } + + /*将MAC地址写入所需结构*/ + for(int i=0;i<6;i++) + { + //以太网帧的目标MAC,即广播MAC,全1 + eth_req->h_dest[i] = (unsigned char)0xff; + //ARP请求包目标MAC,全0 + arp_req->target_mac[i] = (unsigned char)0x00; + //以太网帧源MAC,即本机MAC + //ifr_hwaddr是sockaddr结构体格式 + eth_req->h_source[i] = (unsigned char)ifr.ifr_hwaddr.sa_data[i]; + //ARP请求包源MAC,即本机MAC + arp_req->sender_mac[i] = (unsigned char)ifr.ifr_hwaddr.sa_data[i]; + //sockaddr中的MAC,也是本地MAC + sock_addr.sll_addr[i] = (unsigned char)ifr.ifr_hwaddr.sa_data[i]; + } + + /*打印MAC地址*/ + printf("网卡MAC地址: %02X:%02X:%02X:%02X:%02X:%02X\n", + eth_req->h_source[0], + eth_req->h_source[1], + eth_req->h_source[2], + eth_req->h_source[3], + eth_req->h_source[4], + eth_req->h_source[5]); + + /*完善sockaddr_ll结构体*/ + sock_addr.sll_family = PF_PACKET; + sock_addr.sll_protocol = htons(ETH_P_ARP); + sock_addr.sll_ifindex = ifindex; + sock_addr.sll_hatype = htons(ARPHRD_ETHER); + sock_addr.sll_halen = ETH_ALEN; + + /*完善以太网帧头*/ + eth_req->h_proto = htons(ETH_P_ARP); + + /*完善ARP包头*/ + arp_req->hardware_type = htons(0x01); + arp_req->protocol_type = htons(ETH_P_IP); + arp_req->hardware_size = ETH_ALEN; + arp_req->protocol_size = IPV4_LENGTH; + arp_req->opcode = htons(ARPOP_REQUEST); + memcpy(arp_req->sender_ip,sender_ip,IPV4_LENGTH); + memcpy(arp_req->target_ip,target_ip,IPV4_LENGTH); + + /*发送ARP请求*/ + if(sendto(sock_fd, buffer, 60, 0, (struct sockaddr*)&sock_addr, sizeof(sock_addr)) == -1) + { + perror("sendto()"); + exit(-1); + } + printf("发送ARP请求包:"); + for(int i=0;i<60;i++) + { + if(i%16==0) + printf("\n\t"); + printf("%02X ",buffer[i]); + } + close(sock_fd); + return 0; +} \ No newline at end of file diff --git a/Network/gjb_S0101803GN_2.c b/Network/gjb_S0101803GN_2.c new file mode 100644 index 0000000..cfac623 --- /dev/null +++ b/Network/gjb_S0101803GN_2.c @@ -0,0 +1,84 @@ +/********************************************************************************************************* +** +** GJB 标准测试集 +** +** Copyright All Rights Reserved +** +**--------------文件信息-------------------------------------------------------------------------------- +** +** 文 件 名: gjb_S0101803GN_2.c +** +** 文件创建日期: 2021 年 1 月 12 日 +** +** 描 述: 基本网络协议支持功能测试。编制测试用例代码,通过调 +** 用TCP、UDP、IP、ICMP和ARP协议接口,验证各项协议正 +** 确性,同时利用网络协议分析工具,分析网络包的正确性。 +** IP +** +** !!!!使用 wireshark 抓包工具进行分析查看 +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include + +#ifndef TEST_IP +#define TEST_IP "192.168.6.128" +#endif + +#define IP_ADDR TEST_IP + +int main(int argc, char **argv) +{ + char buf[] = { "hello world" }; + struct sockaddr_in addr; + // int fd = socket(AF_INET, SOCK_RAW, IPPROTO_IP); + // int fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP)); + int fd; + if ((fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP))) < 0) + { + perror(strerror(errno)); + fprintf(stdout, "create socket error\n"); + exit(0); + } + + //socket建立测试 + // if (fd < 0) { + // printf( "child socket error!\n"); + // return (-1); + // } + + //清空接收服务器地址 + memset(&addr, 0, sizeof(addr)); + + //配置接收端服务器 + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr(IP_ADDR); + addr.sin_port = htons(8080); + + //发送数据 + sendto(fd, buf, sizeof(buf), 0, (struct sockaddr *)&addr, sizeof(addr)); + + //关闭socket + close(fd); + + return 0; +} diff --git a/Network/gjb_S0101803GN_3.c b/Network/gjb_S0101803GN_3.c new file mode 100644 index 0000000..238f73f --- /dev/null +++ b/Network/gjb_S0101803GN_3.c @@ -0,0 +1,80 @@ +/********************************************************************************************************* +** +** GJB ׼Լ +** +** Copyright All Rights Reserved +** +**--------------ļϢ-------------------------------------------------------------------------------- +** +** : gjb_S0101803GN_3.c +** +** ļ: 2021 1 12 +** +** : Эֹ֧ܲԡƲ룬ͨ +** TCPUDPIPICMPARPЭӿڣ֤Э +** ȷԣͬʱЭߣȷԡ +** ICMP +** +** ping ԶICMPв +** +** !!!!ʹ wireshark ץ߽з鿴 +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef TEST_PC_IP +#define TEST_PC_IP "192.168.6.128" +#endif + +#define IP_ADDR TEST_PC_IP + +int main(int argc, char **argv) +{ + char buf[] = { "hello world" }; + struct sockaddr_in addr; + int fd ; + if((socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0){ + perror(strerror(errno)); + printf("child socket error!\n"); + return -1; + } + + //socket + // if (fd < 0) { + // printf("child socket error!\n"); + // return -1; + // // GJB_PRT_ERROR_INFO( "child socket error!\n"); + // // return (GJB_PRI_FAIL()); + // } + + //սշַ + memset(&addr, 0, sizeof(addr)); + + //ýն˷ + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr(IP_ADDR); + addr.sin_port = htons(8080); + + // + sendto(fd, buf, sizeof(buf), 0, (struct sockaddr *)&addr, sizeof(addr)); + + //رsocket + close(fd); + return 0; + // return (GJB_PRI_PASS()); +} + + diff --git a/Network/gjb_S0101803GN_4.c b/Network/gjb_S0101803GN_4.c new file mode 100644 index 0000000..8703a13 --- /dev/null +++ b/Network/gjb_S0101803GN_4.c @@ -0,0 +1,76 @@ +/********************************************************************************************************* +** +** GJB 标准测试集 +** +** Copyright All Rights Reserved +** +**--------------文件信息-------------------------------------------------------------------------------- +** +** 文 件 名: gjb_S0101803GN_4.c +** +** 文件创建日期: 2021 年 1 月 12 日 +** +** 描 述: 基本网络协议支持功能测试。编制测试用例代码,通过调 +** 用TCP、UDP、IP、ICMP和ARP协议接口,验证各项协议正 +** 确性,同时利用网络协议分析工具,分析网络包的正确性。 +** TCP +** +** !!!!使用 wireshark 抓包工具进行分析查看 +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifndef TEST_PC_IP +#define TEST_PC_IP "192.168.6.128" +#endif + +#define IP_ADDR TEST_PC_IP + +int main(int argc, char **argv) +{ + char buf[] = { "hello world" }; + struct sockaddr_in addr; + // int fd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP); + int fd; + if ((fd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP)) < 0) + { + perror(strerror(errno)); + fprintf(stdout, "create socket error\n"); + exit(0); + } + //socket建立测试 + // if (fd < 0) { + // GJB_PRT_ERROR_INFO( "socket error!\n"); + // return (GJB_PRI_FAIL()); + // } + + //清空接收服务器地址 + memset(&addr, 0, sizeof(addr)); + + //配置接收端服务器 + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr(IP_ADDR); + addr.sin_port = htons(8080); + + //发送数据 + sendto(fd, buf, sizeof(buf), 0, (struct sockaddr *)&addr, sizeof(addr)); + + //关闭socket + close(fd); + return 0; + // return (GJB_PRI_PASS()); +} diff --git a/Network/gjb_S0101803GN_5.c b/Network/gjb_S0101803GN_5.c new file mode 100644 index 0000000..0ed4256 --- /dev/null +++ b/Network/gjb_S0101803GN_5.c @@ -0,0 +1,77 @@ +/********************************************************************************************************* +** +** GJB 标准测试集 +** +** Copyright All Rights Reserved +** +**--------------文件信息-------------------------------------------------------------------------------- +** +** 文 件 名: gjb_S0101803GN_5.c +** +** 文件创建日期: 2021 年 1 月 12 日 +** +** 描 述: 基本网络协议支持功能测试。编制测试用例代码,通过调 +** 用TCP、UDP、IP、ICMP和ARP协议接口,验证各项协议正 +** 确性,同时利用网络协议分析工具,分析网络包的正确性。 +** UDP +** +** !!!!使用 wireshark 抓包工具进行分析查看 +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef TEST_PC_IP +#define TEST_PC_IP "192.168.6.128" +#endif + +#define IP_ADDR TEST_PC_IP + +int main(int argc, char **argv) +{ + char buf[] = { "hello world" }; + int fd ; + struct sockaddr_in addr; + + //socket建立测试 + if ((socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) < 0) { + perror(strerror(errno)); + fprintf(stdout, "create socket error\n"); + exit(0); + // return -1; + // GJB_PRT_ERROR_INFO( "socket error!\n"); + // return (GJB_PRI_FAIL()); + } + + //清空接收服务器地址 + memset(&addr, 0, sizeof(addr)); + + //配置接收端服务器 + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = inet_addr(IP_ADDR); + addr.sin_port = htons(8080); + + if(connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) + printf("connect() error!"); + + + //发送数据 + sendto(fd, buf, sizeof(buf), 0, (struct sockaddr *)&addr, sizeof(addr)); + + //关闭socket + close(fd); + + return (0); +} diff --git a/Network/gjb_S0101804GN_3.c b/Network/gjb_S0101804GN_3.c new file mode 100644 index 0000000..3ad7dc5 --- /dev/null +++ b/Network/gjb_S0101804GN_3.c @@ -0,0 +1,70 @@ +/********************************************************************************************************* +** +** GJB 标准测试集 +** +** Copyright All Rights Reserved +** +**--------------文件信息-------------------------------------------------------------------------------- +** +** 文 件 名: gjb_S0101804GN_3.c +** +** 文件创建日期: 2021 年 1 月 12 日 +** +** 描 述: 协议栈信息统计功能测试。编制测试用例代码,调用恰当 +** 接口函数获取协议栈统计信息 +** +** routes。 +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + + + +int main() { + // 创建套接字并绑定到任意接口 + int sock = socket(AF_INET, SOCK_STREAM, 0); + struct sockaddr_in addr; + addr.sin_family = AF_INET; + addr.sin_addr.s_addr = htonl(INADDR_ANY); + addr.sin_port = htons(80); // 假设使用HTTP协议监听所有接口 + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + perror("bind failed"); + exit(1); + } + + // 获取网络接口信息 + struct ifaddrs *ifaddr, *ifa; + getifaddrs(&ifaddr); + + // 遍历接口并输出路由信息 + for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { + if (ifa->ifa_addr->sa_family == AF_INET) { // 检查是否为IPv4接口 + struct sockaddr_in *addrp = (struct sockaddr_in *)ifa->ifa_addr; + char ip[INET_ADDRSTRLEN]; + if (inet_ntop(AF_INET, &addrp->sin_addr, ip, sizeof(ip))) { // 将IP地址转换为字符串 + printf("Interface %s has IP address %s\n", ifa->ifa_name, ip); + struct sockaddr_in gw; + if (getnameinfo((struct sockaddr *)&ifa->ifa_dstaddr, ifa->ifa_dstaddr->sa_family == AF_INET ? sizeof(gw) : 0, NULL, 0, NULL, 0, NI_NUMERICHOST ) == 0) { // 获取网关地址并输出 + printf("Interface %s has route to %s\n", ifa->ifa_name, ifa->ifa_dstaddr->sa_family == AF_INET ? inet_ntoa(gw.sin_addr) : "any"); + } else { + // printf("Failed to get route to %s\n", ifa->ifa_dstaddr->sa_family == AF_INET ? inet_ntoa(*(struct in_addr *)&ifa->ifa_dstaddr->sa_addr) : "any"); + } + } + } + } + + // 释放接口信息结构体的内存 + freeifaddrs(ifaddr); // 只需要调用一次freeifaddrs函数,因为它已经将所有接口信息释放了内 + close(sock); // 关闭套接字,释放资源。在C语言中,我们通常在完成操作后关闭资源,以防止资源泄漏。这里我们 + return 0; // 程序正常结束并返回0表示成功。如果在处理过程中发生错误或异常情况,需要返回一 +} diff --git a/Network/gjb_S0101804GN_4.c b/Network/gjb_S0101804GN_4.c new file mode 100644 index 0000000..e0df7eb --- /dev/null +++ b/Network/gjb_S0101804GN_4.c @@ -0,0 +1,173 @@ +/********************************************************************************************************* +** +** GJB ��׼���Լ� +** +** Copyright All Rights Reserved +** +**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +** +** �� �� ��: gjb_S0101804GN_4.c +** +** �ļ���������: 2021 �� 1 �� 12 �� +** +** �� ��: Э��ջ��Ϣͳ�ƹ��ܲ��ԡ����Ʋ����������룬����ǡ�� +** �ӿں�����ȡЭ��ջͳ����Ϣ-- +** +** tcp�� +** ��������Ҫʹ�� tools/USR-TCP232-Test.exe ���߽�����ϲ��� +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// tcp+ +#include +#include + + + +#ifndef TEST_IP +#define TEST_IP "192.168.6.128" +#endif +#ifndef TEST_PC_IP +#define TEST_PC_IP "192.168.6.128" +#endif + +int tcp_show(); + +int main() +{ + int s,on = 1; + int ret1 = -2; + int ret2 = -2; + int ret3 = -2; + int ret4 = -2; + int ret5 = -2; + int ret6 = -2; + int newSock; + struct sockaddr_in addr; + struct sockaddr_in srvr; + socklen_t addrLen; + char recvbuf[1024] = {0}; + int buf_len = sizeof(recvbuf); + char sendbuf[] = "This is a message from " TEST_PC_IP; + int buf_len1 = sizeof(sendbuf); + + s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (s == -1) { + printf( "socket error!\n"); + return (-1); + } else { + printf( "socket success!\n"); + } + + ret1 = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)); + if (ret1 == -1) { + printf( "setsockopt error!\n"); + return (-1); + } else { + printf( "setsockopt success!\n"); + } + + socklen_t size = sizeof(on); + ret6 = getsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, &size); + if (ret6 == -1) { + printf( "getsockopt error!\n"); + return (-1); + } else { + printf( "getsockopt success!\n"); + } + + memset(&srvr, 0, sizeof(srvr)); + + srvr.sin_family = AF_INET; + srvr.sin_port = htons(8080); + srvr.sin_addr.s_addr =inet_addr(TEST_IP); + + ret2 = bind(s, (struct sockaddr *)&srvr, sizeof(srvr)); + if (ret2 == -1) { + printf( "bind error!\n"); + return (-1); + } else { + printf( "bind success!\n"); + } + + ret3 = listen(s, 10); + if (ret3 == -1) { + printf( "listen error!\n"); + return (-1); + } else { + printf( "listen success!\n"); + } + + memset(&addr, 0, sizeof(addr)); + + addrLen = sizeof (struct sockaddr); + + printf("please start PC TCP client and push \"start\"\n"); + + newSock = accept(s, (struct sockaddr *)&addr, &addrLen); + if (newSock == -1) { + printf( "accept error!\n"); + return (-1); + } else { + printf( "accept success!\n"); + } + + ret4 = recv(newSock, recvbuf, buf_len, 0); + if (ret4 == -1) { + printf( "recv error!\n"); + return (-1); + } else { + printf("recvbuf is %s\n",recvbuf); + printf( "recv success!\n"); + } + + ret5 = send(newSock, sendbuf, buf_len1, 0); + if (ret5 == -1) { + printf( "send error!\n"); + return (-1); + } else { + printf( "send success!\n"); + } + + printf("display TCP information:\n"); + // tcp_show(); + + return (0); +} + +int tcp_show(){ + int sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock == -1) { + perror("socket"); + exit(1); + } + + struct tcp_info tcpinfo; + socklen_t len = sizeof(tcpinfo); + if (getsockopt(sock, IPPROTO_TCP, TCP_INFO, &tcpinfo, &len) == -1) { + perror("getsockopt"); + close(sock); + exit(1); + } + + printf("TCP Statistics:\n"); + printf(" RTT: %u ms\n", tcpinfo.tcpi_rtt); + printf(" RTO: %u ms\n", tcpinfo.tcpi_rto); + printf(" Send buffer size: %u bytes\n", tcpinfo.tcpi_rcv_mss); + printf(" Receive buffer size: %u bytes\n", tcpinfo.tcpi_rcv_mss); + printf(" Number of retransmissions: %u\n", tcpinfo.tcpi_total_retrans); + + close(sock); + return 0; +} diff --git a/Network/gjb_S0101804GN_5.c b/Network/gjb_S0101804GN_5.c new file mode 100644 index 0000000..003a830 --- /dev/null +++ b/Network/gjb_S0101804GN_5.c @@ -0,0 +1,103 @@ +/********************************************************************************************************* +** +** GJB ��׼���Լ� +** +** Copyright All Rights Reserved +** +**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +** +** �� �� ��: gjb_S0101804GN_5.c +** +** �ļ���������: 2021 �� 1 �� 12 �� +** +** �� ��: Э��ջ��Ϣͳ�ƹ��ܲ��ԡ����Ʋ����������룬����ǡ�� +** �ӿں�����ȡЭ��ջͳ����Ϣ-- +** +** udp. +** +** ��������Ҫʹ�� tools/USR-TCP232-Test.exe ���߽�����ϲ��� +** +** TEST_IP ��Ҫ����Ϊ���ǵ� PC ip +*********************************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef TEST_IP +#define TEST_IP "192.168.6.128" +#endif + +int main() +{ + int s,on = 1; + int ret; + socklen_t len; + struct sockaddr_in srvr,clientAddr; + char recvBuf[64] = {0}; + + memset(&srvr, 0, sizeof(srvr)); + memset(&clientAddr, 0, sizeof(clientAddr)); + memset(recvBuf, 0, 64); + srvr.sin_family = AF_INET; + srvr.sin_addr.s_addr = htonl(INADDR_ANY); + srvr.sin_port = htons(8080); + + clientAddr.sin_family = AF_INET; + clientAddr.sin_port = htons(8080); + clientAddr.sin_addr.s_addr = inet_addr(TEST_IP); + + s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (s == -1) { + printf( "socket error!\n"); + return (-1); + } else { + printf( "socket success!\n"); + } + + ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)); + if (ret == -1) { + printf( "setsockopt error!\n"); + return (-1); + } else { + printf( "setsockopt success!\n"); + } + + ret = bind(s, (struct sockaddr *)&srvr, sizeof(srvr)); + if (ret == -1) { + printf( "bind error!\n"); + return (-1); + + } else { + printf( "bind success!\n"); + } + + printf("please start PC UDP server add push \"start\"\n"); + + len = sizeof(srvr); + + while (1) { + ret = recvfrom(s, recvBuf, 64, 0, (struct sockaddr *)&clientAddr, &len); + if (ret == -1) { + printf( "recvfrom error!\n"); + return (-1); + } else { + printf("recvbuf is %s\n",recvBuf); + printf( "recvfrom success!\n"); + } + + printf("display UDP information:\n"); + // udp_show(); + } + + return 0; + // return (GJB_PRI_PASS()); +} \ No newline at end of file diff --git a/security/README b/security/README index 506d597..4880371 100644 --- a/security/README +++ b/security/README @@ -1 +1,5 @@ -###安全管理 \ No newline at end of file +###安全管理 + +## 2:pthread_delay报错,gjb_os_binding 改为bind 剩下glibc错误 +##3 TIMER_RELATIVE_C 报错找不到解决办法,O_RDWR未定义 +##5 gjb_os_illeagal_code找不到。pthread_delay报错 \ No newline at end of file diff --git a/security/gjb_S0101611AQ.c b/security/gjb_S0101611AQ.c new file mode 100644 index 0000000..b9b6d77 --- /dev/null +++ b/security/gjb_S0101611AQ.c @@ -0,0 +1,369 @@ +/* + * S0101604GN.c + * + * Created on: Jan 12, 2021 + * Author: xiaolixue + * + * Description: + * 文件系统掉电安全性测试。目标机上电启动,使用继电器控制电源, + * 使操作系统在正常运行过程中目标机断开电源,模拟异常掉电情况, + * 重复操作200次;编写测试用例代码,在目标机上创建文件,并进行 + * 读写操作,验证异常掉电后文件系统仍能正常工作. + * + * 针对 SylixOS 平台掉电安全文件系统测试程序 + * + * 使用说明, 该程序需要在 SylixOS 系统启动之后自动启动, 一段时间后(例如: 2分钟)将目标板进行断电, + * 然后再上电, 如此过程连续操作 200 次或更多, 通常可以通过继电器实现自动 断电和上电 操作. + * + * 该程序编译完成功之后, 可以修改 /etc/startup.sh 的内容, 将该程序加入启动脚本 + */ +#include +#include +#include +#include +#include +#include + +#define FILESIZE (500 * 1024 * 1024) +#define FILEA "/apps/testsuite_ml/result.log" +#define FILEB "/apps/testsuite_ml/abc12.txt" +#define FILEC "/media/sdcard3/c.txt" +#define FILED "/media/sdcard3/d.txt" +#define FILEE "/media/hdd0/e.txt" +#define FILEF "/media/hdd0/f.txt" + +/******************************************************************************************************* +** 函数名称: tTest1 +** 功能描述: eMMC测试 +** 输 入 : +** 输 出 : +*******************************************************************************************************/ +PVOID tTest1_fs_611(PVOID pvArg) +{ + int testfdA; + int testfdB; + int i = 1; + char buf[5] = { 0 }; + struct stat stA; + struct stat stB; + + sleep(2); + + while (1) { + if (access(FILEA, F_OK) == 0) { + stat(FILEA, &stA); + + if (stA.st_size < FILESIZE) { + testfdA = open(FILEA, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdA < 0) { + fprintf(stderr, "open fileA1: files failed.\n"); + return NULL; + } + + while (1) { + sprintf(buf, "%d ", i); + write(testfdA, buf, sizeof(buf)); + fsync(testfdA); + i++; + if (i % 1000 == 0) { + printf("file %s write.\n", FILEA); + } + } + + close(testfdA); + } else { + + remove(FILEA); + + printf("file %s operater success.\n", FILEA); + + testfdB = open(FILEB, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdB < 0) { + fprintf(stderr, "open fileB1: files failed.\n"); + return NULL; + } + + close(testfdB); + continue; + } + + } else if (access(FILEB, F_OK) == 0) { + stat(FILEB, &stB); + + if (stB.st_size < FILESIZE) { + + testfdB = open(FILEB, O_RDWR | O_CREAT | O_APPEND,0666); + + while (1) { + sprintf(buf, "%d ", i); + + if (testfdB < 0) { + fprintf(stderr, "open fileB2: files failed.\n"); + return NULL; + } + + write(testfdB, buf, sizeof(buf)); + + fsync(testfdB); + i++; + + if (i % 1000 == 0) { + printf("file %s write.\n", FILEB); + } + } + + close(testfdB); + } else { + remove(FILEB); + + printf("file %s operater success.\n", FILEB); + testfdA = open(FILEA, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdA < 0) { + fprintf(stderr, "open fileA2: files failed.\n"); + return NULL; + } + + close(testfdA); + continue; + } + } else { + testfdA = open(FILEA, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdA < 0) { + fprintf(stderr, "open fileA3: files failed.\n"); + return NULL; + } + close(testfdA); + } + } + + return NULL; +} +/******************************************************************************************************* +** 函数名称: tTest2 +** 功能描述: SD-Card 测试 +** 输 入 : +** 输 出 : +*******************************************************************************************************/ +PVOID tTest2_fs_611(PVOID pvArg) +{ + int testfdC; + int testfdD; + int i = 1; + char buf[5] = { 0 }; + struct stat stC; + struct stat stD; + + sleep(2); + + while (1) { + if (access(FILEC, F_OK) == 0) { + stat(FILEC, &stC); + if (stC.st_size < FILESIZE) { + testfdC = open(FILEC, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdC < 0) { + fprintf(stderr, "open fileC1: files failed.\n"); + return NULL; + } + + while (1) { + sprintf(buf, "%d ", i); + write(testfdC, buf, sizeof(buf)); + + fsync(testfdC); + i++; + } + close(testfdC); + + } else { + remove(FILEC); + testfdD = open(FILED, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdD < 0) { + fprintf(stderr, "open fileD1: files failed.\n"); + return NULL; + } + close(testfdD); + continue; + } + + } else if (access(FILED, F_OK) == 0) { + stat(FILED, &stD); + + if (stD.st_size < FILESIZE) { + + testfdD = open(FILED, O_RDWR | O_CREAT | O_APPEND,0666); + + while (1) { + sprintf(buf, "%d ", i); + + if (testfdD < 0) { + fprintf(stderr, "open fileD2: files failed.\n"); + return NULL; + } + + write(testfdD, buf, sizeof(buf)); + + fsync(testfdD); + i++; + } + + close(testfdD); + } else { + remove(FILED); + + testfdC = open(FILEC, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdC < 0) { + fprintf(stderr, "open fileC2: files failed.\n"); + return NULL; + } + + close(testfdC); + continue; + } + } else { + testfdC = open(FILEC, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdC < 0) { + fprintf(stderr, "open fileC3: files failed.\n"); + return NULL; + } + close(testfdC); + } + } + + return NULL; +} +/******************************************************************************************************* +** 函数名称: tTest3 +** 功能描述: SSD 测试 +** 输 入 : +** 输 出 : +*******************************************************************************************************/ +PVOID tTest3_fs_611(PVOID pvArg) +{ + int testfdE; + int testfdF; + int i = 1; + char buf[5] = { 0 }; + struct stat stE; + struct stat stF; + + sleep(2); + + while (1) { + if (access(FILEE, F_OK) == 0) { + stat(FILEE, &stE); + if (stE.st_size < FILESIZE) { + testfdE = open(FILEE, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdE < 0) { + fprintf(stderr, "open fileE1: files failed.\n"); + return NULL; + } + + while (1) { + sprintf(buf, "%d ", i); + write(testfdE, buf, sizeof(buf)); + + fsync(testfdE); + i++; + + } + close(testfdE); + + } else { + remove(FILEE); + + printf("file %s operater success.\n", FILEE); + + testfdF = open(FILEB, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdF < 0) { + fprintf(stderr, "open fileF1: files failed.\n"); + return NULL; + } + close(testfdF); + continue; + } + + } else if (access(FILEF, F_OK) == 0) { + stat(FILEF, &stF); + + if (stF.st_size < FILESIZE) { + + testfdF = open(FILEF, O_RDWR | O_CREAT | O_APPEND,0666); + + while (1) { + sprintf(buf, "%d ", i); + + if (testfdF < 0) { + fprintf(stderr, "open fileF2: files failed.\n"); + return NULL; + } + + write(testfdF, buf, sizeof(buf)); + + fsync(testfdF); + i++; + } + close(testfdF); + + } else { + remove(FILEF); + + printf("file %s operater success.\n", FILEF); + + testfdE = open(FILEE, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdE < 0) { + fprintf(stderr, "open fileE2: files failed.\n"); + return NULL; + } + close(testfdE); + continue; + } + + } else { + testfdE = open(FILEE, O_RDWR | O_CREAT | O_APPEND,0666); + if (testfdE < 0) { + fprintf(stderr, "open fileE3: files failed.\n"); + return NULL; + } + close(testfdE); + } + } + + return NULL; +} +/******************************************************************************************************* +** 函数名称: tTest3 +** 功能描述: 测试程序主函数 +** 输 入 : +** 输 出 : +*******************************************************************************************************/ +int gjb_S0101611AQ(int argc, char **argv) +{ + pthread_t hThreadId1, hThreadId2,hThreadId3; + pthread_attr_t threadattr1, threadattr2,threadattr3; + cpu_set_t cpuset; + + pthread_attr_init(&threadattr1); +// pthread_attr_init(&threadattr2); + //pthread_attr_init(&threadattr3); // SD卡测试 + + pthread_create(&hThreadId1, &threadattr1, tTest1_fs_611, NULL); +// pthread_create(&hThreadId2, &threadattr2, tTest2_fs_611, NULL); + //pthread_create(&hThreadId3, &threadattr3, tTest3_fs_611, NULL); // SD卡测试 + + CPU_ZERO(&cpuset); + CPU_SET(0, &cpuset); + pthread_setaffinity_np(hThreadId1, sizeof(cpu_set_t), &cpuset); /* 设置线程hThreadld1在CPU1上运行*/ + +// CPU_ZERO(&cpuset); +// CPU_SET(2, &cpuset); +// pthread_setaffinity_np(hThreadId2, sizeof(cpu_set_t), &cpuset); /* 设置线程hThreadld2在CPU2上运行*/ + + /* + * SD 卡测试 + */ + //CPU_ZERO(&cpuset); + //CPU_SET(3, &cpuset); + //pthread_setaffinity_np(hThreadId3, sizeof(cpu_set_t), &cpuset); /* 设置线程hThreadld3在CPU3上运行*/ + + return (ERROR_NONE); +} diff --git a/security/gjb_S0102601AQ_deadlock.c b/security/gjb_S0102601AQ_deadlock.c new file mode 100644 index 0000000..b2769c9 --- /dev/null +++ b/security/gjb_S0102601AQ_deadlock.c @@ -0,0 +1,214 @@ +/********************************************************************************************************* +** +** GJB ׼Լ +** +** Copyright All Rights Reserved +** +**--------------ļϢ-------------------------------------------------------------------------------- +** +** : gjb_S0102601AQ_deadlock.c +** +** ļ: 2021 1 12 +** +** : , sylixOS ͨ tp 鿴״̬ +*********************************************************************************************************/ +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif + +#include "gjb.h" + +sem_t Csem; +sem_t Dsem; + +static pthread_t thread_id3; +static pthread_t thread_id4; +static pthread_attr_t thread_attr3; +static pthread_attr_t thread_attr4; + +void *Fun3_security_1 (void *arg) +{ + int res = -100; + int nDelaytime = 800; + + GJB_PRT_INFO("Task3 is running\n"); + + //ȡCֵźԴ + res = sem_wait(&Csem); + if (res == 0) { + GJB_PRT_INFO("Task3 Get Csem Succesful\n"); + } else { + GJB_PRT_ERROR_INFO("Task3 Get Csem Failed\n"); + } + + //ʱ + sleep(2); + + //ȡDźԴ + res = -100; + res = sem_wait(&Dsem); + if (res == 0) { + GJB_PRT_INFO("Task3 Get Dsem Succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task3 Get Dsem Failed\n"); + } + + //ʱ + pthread_delay(nDelaytime); //1000ticks + res = -100; + res = sem_post(&Csem); + if (res == 0) { + GJB_PRT_INFO("Task3 Release Csem succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task3 Release Csem Failed\n"); + } + + //ʱ + pthread_delay(nDelaytime); //1000ticks + + res = -100; + res = sem_post(&Dsem); + if (res == 0) { + GJB_PRT_INFO("Task3 Release Dsem succesful\n"); + } else { + GJB_PRT_ERROR_INFO("Task3 Release Dsem Failed\n"); + } + + return NULL; +} + +void *Fun4_security_1 (void *arg) +{ + int res = -100; + int nDelaytime = 1000; //ʱʱ + + GJB_PRT_INFO("Task4 is running\n"); + + //ȡCֵźԴ + res = sem_wait(&Dsem); + if (res == 0) { + GJB_PRT_INFO("Task4 Get Dsem succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task4 Get Dsem Failed\n"); + goto error; + } + + //ʱ + sleep(2); + + //ȡDźԴ + res = -100; + res = sem_wait(&Csem); + if (res == 0) { + GJB_PRT_INFO("Task4 Get Csem succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task4 Get Csem Failed\n"); + goto error; + } + + //ʱ + pthread_delay(nDelaytime); //1000ticks + + res = -100; + res = sem_post(&Dsem); + if (res == 0) { + GJB_PRT_INFO("Task4 Release Dsem succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task4 Release Dsem Failed\n"); + goto error; + } + + //ʱ + pthread_delay(nDelaytime); //1000ticks + + res = -100; + res = sem_post(&Csem); + if (res == 0) { + GJB_PRT_INFO("Task4 Release Csem succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task4 Release Csem Failed\n"); + goto error; + } + + return NULL; + +error: + return ((void *)123); +} + +//ں +int Test_S0102101AQ_2 (void) +{ + int status = -100; + + //ֵźʼ + sem_init(&Csem, 0, 1); + sem_init(&Dsem, 0, 1); + + // + pthread_attr_init(&thread_attr3); + pthread_attr_init(&thread_attr4); + + thread_attr3.stackaddr = NULL; + thread_attr3.stacksize = PTHREAD_STACK_MIN * 2; + thread_attr3.inheritsched = PTHREAD_EXPLICIT_SCHED; + thread_attr3.schedpolicy = SCHED_FIFO; + thread_attr3.schedparam.sched_priority = 100; + thread_attr3.name = "Task3"; + + thread_attr4.stackaddr = NULL; + thread_attr4.stacksize = PTHREAD_STACK_MIN * 2; + thread_attr4.inheritsched = PTHREAD_EXPLICIT_SCHED; + thread_attr4.schedpolicy = SCHED_FIFO; + thread_attr4.schedparam.sched_priority = 100; + thread_attr4.name = "Task4"; + + status = -100; + + status = pthread_create(&thread_id3, &thread_attr3, Fun3_security_1, NULL); + if (status == 0) { + GJB_PRT_INFO("Task3 create succesful\n"); + + } else { + GJB_PRT_ERROR_INFO("Task3 create Failed\n"); + } + + status = -100; + status = pthread_create(&thread_id4, &thread_attr4, Fun4_security_1, NULL); + if (status == 0) { + GJB_PRT_INFO( "Task4 create succesful\n"); + + } else { + GJB_PRT_ERROR_INFO( "Task4 create Failed\n"); + } + + pthread_join(thread_id3, NULL); + pthread_join(thread_id4, NULL); + + return (0); +} +/********************************************************************** + * ƣ GJB_ENTRY() + * û + * + * + * ֵ + * ˵ + **************************************************************************/ +int gjb_S0102601AQ_deadlock(int argc, char **argv) +{ + int result; + + result = Test_S0102101AQ_2(); /* security */ + if (result != 0) { + return (GJB_PRI_FAIL()); + } + + return (GJB_PRI_PASS()); +} diff --git a/security/gjb_S0102602AQ.c b/security/gjb_S0102602AQ.c new file mode 100644 index 0000000..2857381 --- /dev/null +++ b/security/gjb_S0102602AQ.c @@ -0,0 +1,255 @@ +/********************************************************************************************************* +** +** GJB ��׼���Լ� +** +** Copyright All Rights Reserved +** +**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +** +** �� �� ��: gjb_S0102602AQ.c +** +** �ļ���������: 2021 �� 1 �� 12 �� +** +** �� ��: ��֤���ȼ���ת�㷨, ����3���̣߳����ȼ�Ϊ �� �� ��, �����ȼ��߳��Ȼ�û�����, �����ȼ��߳̿�ʼ����, һ��ʱ�� +** �����ȼ��߳����в����Ի���������ȡʧ�ܣ������ȼ��߳̿�ʼ����(��ʱ�����ȼ��߳�) +*********************************************************************************************************/ +include +#include +#include +#include +#include + +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif + +//#include "gjb.h" + +static pthread_mutex_t Amutex; +static pthread_barrier_t bt; +static pthread_t thread_id1; +static pthread_t thread_id2; +static pthread_t thread_id3; +static pthread_attr_t thread_attr1; +static pthread_attr_t thread_attr2; +static pthread_attr_t thread_attr3; + +void *Fun1_2 (void *arg) +{ + volatile int i = 0, j = 0; + int res; + + bind(pthread_self(), 0); + + pthread_barrier_wait(&bt); + + printf("low-task is running\n"); + + //��ȡ������A��Դ + res = -100; + res = pthread_mutex_lock(&Amutex); + + if (res == 0) { + printf("low-task Get Amutex succesful\n"); + + } else { + printf("low-task Get Amutex Failed\n"); + return ((void *)123); + } + + printf("low-task Get Amutex and running\n"); + + for (i = 0; i < 1000; i++) { + for (j = 0; j < 100000; j++); + for (j = 0; j < 1000000; j++); + if (i % 100 == 0) { + printf("low-task Get Amutex and running\n"); + } + } + + res = -100; + res = pthread_mutex_unlock(&Amutex); // �������ȼ��ָ������Իᵼ�¸����ȼ��ȴ�ӡ�ͷ����ɹ� + if (res == 0) { + printf("low-task Release Amutex succesful\n"); + + } else { + printf("low-task Release Amutex Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun2_2 (void *arg) +{ + volatile int i = 0, j = 0; + + bind(pthread_self(), 0); + pthread_barrier_wait(&bt); + + printf("mid-task is running\n"); + + pthread_delay(200); // ��������ȼ���ʼ���У������Ƴ���֤�����ȼ������� + + for (i = 0; i < 1000; i++) { + for (j = 0; j < 100000; j++); + for (j = 0; j < 10000; j++); + if (i % 100 == 0) { + printf("mid-task is running\n"); + } + } + + return NULL; +} + +void *Fun3_3 (void *arg) +{ + int i = 0; + int res; + + bind(pthread_self(), 0); + pthread_barrier_wait(&bt); + + printf("high-task is running\n"); + + pthread_delay(800); // ������ȼ��ó�CPU, ��֤�����ȼ���ʼ���� + printf("high-task reques muext Amutex\n"); + + //��ȡ������A��Դ + res = -100; + res = pthread_mutex_lock(&Amutex); + if (res == 0) { + printf("high-task Get Amutex succesful\n"); + + } else { + printf("high-task Get Amutex Failed\n"); + } + + for (i = 0; i < 10000; i++) { + if (i % 100 == 0) { + printf("high-task Get Amutex and running\n"); + } + } + + res = -100; + res = pthread_mutex_unlock(&Amutex); + if (res == 0) { + printf("high-task Release Amutex succesful\n"); + + } else { + printf("high-task Release Amutex Failed\n"); + return ((void *)123); + } + + return NULL; +} + +//��ں��� +int Test_S0102102AQ_1 (void) +{ + int status = -100; + int nDelaytime = 2; //��ʱ2��ticks + + bind(pthread_self(), 0); + + pthread_barrier_init(&bt, NULL, 4); + + //��������ʼ�� + pthread_mutex_init(&Amutex, NULL); + + //�������� + pthread_attr_init(&thread_attr1); + pthread_attr_init(&thread_attr2); + pthread_attr_init(&thread_attr3); + + // thread_attr1.stackaddr = NULL; + // thread_attr1.stacksize = PTHREAD_STACK_MIN * 2; + // thread_attr1.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr1.schedpolicy = SCHED_RR; + // thread_attr1.schedparam.sched_priority = 100; + // thread_attr1.name = "low"; + + // thread_attr2.stackaddr = NULL; + // thread_attr2.stacksize = PTHREAD_STACK_MIN * 2; + // thread_attr2.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr2.schedpolicy = SCHED_RR; + // thread_attr2.schedparam.sched_priority = 110; + // thread_attr2.name = "mid"; + + // thread_attr3.stackaddr = NULL; + // thread_attr3.stacksize = PTHREAD_STACK_MIN * 2; + // thread_attr3.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr3.schedpolicy = SCHED_RR; + // thread_attr3.schedparam.sched_priority = 120; + // thread_attr3.name = "high"; + + status = -100; + + status = pthread_create(&thread_id3, &thread_attr3, Fun3_3, NULL); + if (status == 0) { + printf("high-task create succesful\n"); + + } else { + printf("high-task create Failed\n"); + goto error; + } + + //��ʱ + pthread_delay(nDelaytime); // 2��ticks + + status = -100; + + status = pthread_create(&thread_id2, &thread_attr2, Fun2_2, NULL); + if (status == 0) { + printf("mid-task create succesful\n"); + + } else { + printf("mid-task create Failed\n"); + goto error; + } + + //��ʱ + pthread_delay(nDelaytime); // 2��ticks + + status = -100; + + status = pthread_create(&thread_id1, &thread_attr1, Fun1_2, NULL); + if (status == 0) { + printf("low-task create succesful\n"); + + } else { + printf("low-task create Failed\n"); + goto error; + } + + + pthread_barrier_wait(&bt); + + pthread_join(thread_id1, NULL); + pthread_join(thread_id2, NULL); + pthread_join(thread_id3, NULL); + + return (0); + +error: + return (-1); +} +/********************************************************************** + * �������ƣ� GJB_ENTRY() + * ���������� �û�������� + * ��������� �� + * ��������� �� + * �� �� ֵ�� �� + * ����˵���� �� + **************************************************************************/ +int main(int argc, char **argv) +{ + int result; + + result = Test_S0102102AQ_1(); /* security */ + if (result != 0) { + return (-1); + } + + return (0); +} diff --git a/security/gjb_S0102603AQ.c b/security/gjb_S0102603AQ.c new file mode 100644 index 0000000..1072fde --- /dev/null +++ b/security/gjb_S0102603AQ.c @@ -0,0 +1,744 @@ +/********************************************************************************************************* +** +** GJB ��׼���Լ� +** +** Copyright All Rights Reserved +** +**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +** +** �� �� ��: gjb_S0102603AQ.c +** +** �ļ���������: 2021 �� 1 �� 20 �� +** +** �� ��: �����꺯���ӿڳ����ȶ��Բ���, ͨ�����ò�ͬ�ĺ����ӿڲ��жϺ����ķ���ֵ +*********************************************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + + + + +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif + +// #include "gjb.h" + +#define TimeLen 1800 +#define DelayTime 30 + +static pthread_t thread_id1; +static pthread_t thread_id2; +static pthread_t thread_id3; +static pthread_t thread_id4; +static pthread_t thread_id5; +static pthread_t thread_id6; +static pthread_t thread_id7; +static pthread_t thread_id8; +static pthread_t thread_id9; +static pthread_t thread_id10; + +static pthread_attr_t thread_attr1; +static pthread_attr_t thread_attr2; +static pthread_attr_t thread_attr3; +static pthread_attr_t thread_attr4; +static pthread_attr_t thread_attr5; +static pthread_attr_t thread_attr6; +static pthread_attr_t thread_attr7; +static pthread_attr_t thread_attr8; +static pthread_attr_t thread_attr9; +static pthread_attr_t thread_attr10; + +static pthread_mutex_t Amutex; +static sem_t Bsem; + +static int bFlag = 0; + +static void *Fun1_security(void *arg); +static void *Fun2_security(void *arg); +static void *Fun3_security(void *arg); +static void *Fun4_security(void *arg); +static void *Fun5_security(void *arg); +static void *Fun6_security(void *arg); +void *Fun7_security(void *arg); +void *Fun8_security(void *arg); +void *Fun9_security(void *arg); +void *Fun10_security(void *arg); +int S0102103AQ(void); + +void handler_xx (int signo) +{ + printf("Fun handler is running\n"); + bFlag = 1; +} + +int Test_S0102103AQ (void) +{ + int res = 0; + clockid_t clock_id = CLOCK_REALTIME; + struct timespec tp; + struct timespec rqtp; + long nTime1, nTime2; + int nRunTimes=0; + + pthread_mutex_init(&Amutex, NULL); + + sem_init(&Bsem, 0, 2); + + if (res == 0) { + res = clock_gettime(clock_id, &tp); + if (res == 0) { + nTime1 = tp.tv_sec; + printf("nTime1 = %ld\n", nTime1); + + } else { + printf("clock_gettime nTime1 error\n"); + return (-1); + } + + } else { + printf("clock_getcpuclockid error\n"); + return (-1); + } + + while (1) { + if (nRunTimes++ % 50 == 0) { + printf("Rounds:%d\n", nRunTimes); + mem_show(); + } + + S0102103AQ(); + + clock_gettime(clock_id, &tp); + + nTime2 = tp.tv_sec; + + printf("Time:\tnTime1 = %ld\tnTime2 = %ld\tnTime2 - nTime1 = %ld\n", nTime1, nTime2, nTime2 - nTime1); + + if (nTime2 - nTime1 > TimeLen) { + pthread_delay(1000); + printf("Time Over! \t nTime1 = %ld \t nTime2 = %ld \t nTime2 - nTime1 = %ld\n", nTime1, nTime2, nTime2 - nTime1); + break; + + } else { + rqtp.tv_sec = DelayTime; + rqtp.tv_nsec = 0; + nanosleep(&rqtp, NULL); + } + } + + return (0); +} + +int S0102103AQ (void) +{ + int res = -100; + + pthread_attr_init(&thread_attr1); + pthread_attr_init(&thread_attr2); + pthread_attr_init(&thread_attr3); + pthread_attr_init(&thread_attr4); + pthread_attr_init(&thread_attr5); + pthread_attr_init(&thread_attr6); + pthread_attr_init(&thread_attr7); + pthread_attr_init(&thread_attr8); + pthread_attr_init(&thread_attr9); + pthread_attr_init(&thread_attr10); + + // thread_attr1.stackaddr = NULL; + // thread_attr1.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr1.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr1.schedpolicy = SCHED_FIFO; + // thread_attr1.schedparam.sched_priority = 90; + // thread_attr1.name = "Task1"; + + // thread_attr2.stackaddr = NULL; + // thread_attr2.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr2.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr2.schedpolicy = SCHED_FIFO; + // thread_attr2.schedparam.sched_priority = 90; + // thread_attr2.name = "Task2"; + + // thread_attr3.stackaddr = NULL; + // thread_attr3.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr3.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr3.schedpolicy = SCHED_FIFO; + // thread_attr3.schedparam.sched_priority = 90; + // thread_attr3.name = "Task3"; + + // thread_attr4.stackaddr = NULL; + // thread_attr4.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr4.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr4.schedpolicy = SCHED_FIFO; + // thread_attr4.schedparam.sched_priority = 100; + // thread_attr4.name = "Task4"; + + // thread_attr5.stackaddr = NULL; + // thread_attr5.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr5.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr5.schedpolicy = SCHED_FIFO; + // thread_attr5.schedparam.sched_priority = 100; + // thread_attr5.name = "Task5"; + + // thread_attr6.stackaddr = NULL; + // thread_attr6.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr6.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr6.schedpolicy = SCHED_FIFO; + // thread_attr6.schedparam.sched_priority = 100; + // thread_attr6.name = "Task6"; + + // thread_attr7.stackaddr = NULL; + // thread_attr7.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr7.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr7.schedpolicy = SCHED_FIFO; + // thread_attr7.schedparam.sched_priority = 110; + // thread_attr7.name = "Task7"; + + // thread_attr8.stackaddr = NULL; + // thread_attr8.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr8.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr8.schedpolicy = SCHED_FIFO; + // thread_attr8.schedparam.sched_priority = 110; + // thread_attr8.name = "Task8"; + + // thread_attr9.stackaddr = NULL; + // thread_attr9.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr9.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr9.schedpolicy = SCHED_FIFO; + // thread_attr9.schedparam.sched_priority = 110; + // thread_attr9.name = "Task9"; + + // thread_attr10.stackaddr = NULL; + // thread_attr10.stacksize = PTHREAD_STACK_MIN*2; + // thread_attr10.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr10.schedpolicy = SCHED_FIFO; + // thread_attr10.schedparam.sched_priority = 120; + // thread_attr10.name = "Task10"; + + res = -100; + res = pthread_create( &thread_id1,&thread_attr1, Fun1_security, NULL ); + if (res == 0) { + printf( "Task1 create succesful\n"); + + } else { + printf( "Task1 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create( &thread_id2,&thread_attr2, Fun2_security, NULL ); + if (res == 0) { + printf( "Task2 create succesful\n"); + + } else { + printf( "Task2 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create( &thread_id3,&thread_attr3, Fun3_security, NULL ); + if (res == 0) { + printf( "Task3 create succesful\n"); + + } else { + printf( "Task3 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create( &thread_id4,&thread_attr4, Fun4_security, NULL ); + if (res == 0) { + printf( "Task4 create succesful\n"); + } else { + printf( "Task4 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create( &thread_id5,&thread_attr5, Fun5_security, NULL ); + if (res == 0) { + printf( "Task5 create succesful\n"); + + } else { + printf( "Task5 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create(&thread_id6,&thread_attr6, Fun6_security, NULL); + if (res == 0) { + printf( "Task6 create succesful\n"); + + } else { + printf( "Task6 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create(&thread_id7,&thread_attr7, Fun7_security, NULL); + if (res == 0) { + printf( "Task7 create succesful\n"); + + } else { + printf( "Task7 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create(&thread_id8,&thread_attr8, Fun8_security, NULL); + if (res == 0) { + printf( "Task8 create succesful\n"); + + } else { + printf( "Task8 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create( &thread_id9,&thread_attr9, Fun9_security, NULL); + if (res == 0) { + printf( "Task9 create succesful\n"); + + } else { + printf( "Task9 create Failed\n"); + goto error; + } + + res = -100; + res = pthread_create(&thread_id10,&thread_attr10, Fun10_security, NULL); + if (res == 0) { + printf( "Task10 create succesful\n"); + + } else { + printf( "Task10 create Failed\n"); + goto error; + } + + pthread_join(thread_id1, NULL); + pthread_join(thread_id2, NULL); + pthread_join(thread_id3, NULL); + pthread_join(thread_id4, NULL); + pthread_join(thread_id5, NULL); + pthread_join(thread_id6, NULL); + pthread_join(thread_id7, NULL); + pthread_join(thread_id8, NULL); + pthread_join(thread_id9, NULL); + pthread_join(thread_id10, NULL); + + return (0); + +error: + return (-1); +} + +void *Fun1_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = pthread_mutex_lock(&Amutex); + if (res != 0) { + printf("Task1:Get Amutex Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime);//1000??ticks + + res = -100; + res = pthread_mutex_unlock(&Amutex); + + if (res != 0) { + printf("Task1:Release Amutex Failed\tres = %d \n", res); + return ((void *)123); + } + + return NULL; +} + +void *Fun2_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = pthread_mutex_lock(&Amutex); + if (res != 0) { + printf("Task2:Get Amutex Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime); + + res = -100; + res = pthread_mutex_unlock(&Amutex); + + if (res != 0) { + printf("Task2:Release Amutex Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun3_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = sem_wait(&Bsem); + if (res != 0) { + printf("Task3:Get Bsem Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime); + + res = sem_post(&Bsem); + if (res != 0) { + printf("Task3:Release Bsem Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun4_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = pthread_mutex_lock(&Amutex); + if (res !=0 ) { + printf("Task4:Get Amutex Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime); + + res = -100; + res = pthread_mutex_unlock(&Amutex); + if (res != 0) { + printf("Task4:Release Amutex Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun5_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = sem_wait(&Bsem); + if (res != 0) { + printf("Task5:Get Bsem Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime); + + res = sem_post(&Bsem); + if (res != 0) { + printf("Task5:Release Bsem Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun6_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = sem_wait(&Bsem); + if (res != 0) { + printf("Task6:Get Bsem Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime); + + res = sem_post(&Bsem); + if (res != 0) { + printf("Task6:Release Bsem Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun7_security (void *arg) +{ + int res = -100; + int nDelaytime = 20; + + res = sem_wait(&Bsem); + if (res != 0) { + printf("Task7:Get Bsem Failed\n"); + return ((void *)123); + } + + pthread_delay(nDelaytime); + + res = sem_post(&Bsem); + if (res != 0) { + printf("Task7:Release Bsem Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun8_security (void *arg) +{ + int res = -100; + timer_t tid; + struct itimerspec ovalue; + struct itimerspec its; + struct sigevent ev; + struct sigaction act; + + ev.sigev_notify = SIGEV_SIGNAL; + ev.sigev_signo = SIGALRM; + + act.sa_handler = handler_xx; + act.sa_flags=0; + + if (sigemptyset(&act.sa_mask) != 0) { + printf("sigemptyset() was not successful\n"); + return ((void *)123); + } + + if (sigaction(SIGALRM, &act, 0) != 0) { + printf("sigaction() was not successful\n"); + return ((void *)123); + } + + bFlag = 0; + + res = timer_create(CLOCK_REALTIME, &ev, &tid); + if (res != 0) { + printf("timer_create Failed\n"); + return ((void *)123); + } + + its.it_interval.tv_sec = 0; its.it_interval.tv_nsec = 0; + its.it_value.tv_sec = 1; its.it_value.tv_nsec = 0; + + res = timer_settime(tid, TIMER_RELATIVE_C, &its, &ovalue); + if (res != 0) { + printf("flag = TIMER_RELACTIVE_C, timer_settime Failed\n"); + return ((void *)123); + } + + sleep(2); + + if (bFlag != 1) { + printf("Task8:DSQ Operate Error\n"); + return ((void *)123); + } + + res = timer_delete(tid); + if (res != 0) { + printf("timer_delete Failed\n"); + return ((void *)123); + } + + return NULL; +} + +void *Fun9_security (void *arg) +{ +#ifdef __TMS320C6X__ +#define MALLOC_NUM (1) +#define MALLOC_ONCE_SIZE (1024 * 1024) +#else +#define MALLOC_NUM (10) +#define MALLOC_ONCE_SIZE (10 * 1024 * 1024) +#endif + int nDelaytime = 20; + int i = 0; + char *nfp[MALLOC_NUM] = {NULL}; + int mid; + int res; + + for (i = 0; i < MALLOC_NUM; i++) { + nfp[i] = (char*)malloc(1024 * (i + 1)); + if (!nfp[i]) { + printf("Task9:malloc Failed\t i = %d\n", i); + return ((void *)123); + } + } + + pthread_delay(2 * nDelaytime); + + for (i = 0; i < MALLOC_NUM; i++) { + if (nfp[i]) { + free(nfp[i]); + } + } + + char *acoinfoaddr = NULL; + acoinfoaddr = (char *)malloc(MALLOC_ONCE_SIZE); + if (acoinfoaddr == NULL) { + printf("malloc error errno: %d!\n", errno); + return ((void *)123); + } + + res = mpart_create(acoinfoaddr, MALLOC_ONCE_SIZE, &mid); + if (res != 0) { + perror("mpart_create"); + printf("Task9:mpart_create Failed %d\n", res); + return ((void *)123); + } + + for (i = 0; i < MALLOC_NUM; i++) { + nfp[i] = (char*)mpart_alloc(mid, 1024 * (i + 1)); + if (!nfp[i]) { + printf("Task9:mpart_alloc Failed\t i = %d\n", i); + return ((void *)123); + } + } + + pthread_delay(nDelaytime); + + for (i = 0; i < MALLOC_NUM; i++) { + if (nfp[i]) { + res = mpart_free(mid, nfp[i]); + if (res != 0) { + printf("Task9: Failed Release\n"); + return ((void *)123); + } + } + } + + res = mpart_delete(mid); + if (res != 0) { + printf("Task9:mpart_delete Failed\n"); + return ((void *)123); + } + + free(acoinfoaddr); + + return NULL; +} + +void *Fun10_security (void *arg) +{ + int res = -100; + int nDelaytime = 3; + char ctr1[50] = {0}; + char ctr2[50] = {0}; + char cname[50] = {0}; + int findle = 0; + int i = 0; + int nflag = 0; + static int ncount = 0; + + sprintf(cname, "%s%d%s", "abc", (ncount++) % 20, ".txt"); + + if (ncount < 21) { + res = creat(cname, 0666); + if (res != -1) { + close(res); + + } else { + printf("Task10: File create Failed\tres = %d\n", res); + printf("errno = %d\n", errno); + return ((void *)123); + } + } + + for (i = 0; i < 50; i++) { + if (i % 2 == 0) { + ctr1[i] = 'A'; + } else { + ctr1[i] = '5'; + } + } + + ctr1[49] = 0; + findle = open(cname, O_RDWR, 0666); + if (findle == -1) { + printf("Write, Open File Failed\n"); + printf("errno = %d\n", errno); + printf("ncount = %d\n", ncount); + return ((void *)123); + } + + res = write(findle, ctr1, 50); + if (res == -1) { + printf("Write File Failed\n"); + printf("errno = %d\n", errno); + close(findle); + return ((void *)123); + } + + pthread_delay(10 * nDelaytime); + + res = close(findle); + if (res != 0) { + printf("Close File Failed\n"); + return ((void *)123); + } + + findle = open(cname, O_RDWR, 0666); + if (findle == -1) { + printf("Read, Open File Failed\n"); + return ((void *)123); + } + + res = read(findle, ctr2, 50); + if (res == -1) { + printf("Read File Failed\n"); + return ((void *)123); + } + + nflag = 0; + + for (i = 0; i < 50; i++) { + if (ctr1[i] != ctr2[i]) { + nflag = 1; + printf("ctr1 = %c\tctr2 = %c\n", ctr1[i], ctr2[i]); + break; + } + } + + if (nflag == 1) { + printf("Read Data Failed\n"); + return ((void *)123); + } + + res = close(findle); + if (res != 0) { + printf("Close File Failed\n"); + return ((void *)123); + } + + return NULL; +} +/********************************************************************** + * �������ƣ� GJB_ENTRY() + * ���������� �û�������� + * ��������� �� + * ��������� �� + * �� �� ֵ�� �� + * ����˵���� �� + **************************************************************************/ +int main(int argc, char **argv) +{ + int result; + + result = Test_S0102103AQ(); /* security */ + if (result != 0) { + return (-1); + } + + return (0); +} diff --git a/security/gjb_S0102605AQ.c b/security/gjb_S0102605AQ.c new file mode 100644 index 0000000..a595a64 --- /dev/null +++ b/security/gjb_S0102605AQ.c @@ -0,0 +1,128 @@ +/********************************************************************************************************* +** +** GJB ׼Լ +** +** Copyright All Rights Reserved +** +**--------------ļϢ-------------------------------------------------------------------------------- +** +** : S0102605.c +** +** ļ: 2021 1 12 +** +** : ͨǷָ쳣, ֤ϵͳ쳣 +*********************************************************************************************************/ +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif +#include + +// #include "gjb.h" + +static pthread_attr_t thread_attr1; +static pthread_t thread_id1; + +void *Fun1_security_1 (void *arg) +{ + printf("Task1 is running-1\n"); + + /* + * Ƿָ쳣, ͬƽ̨úʵֲͬ + */ + gjb_os_illeagal_code(); + + printf("Task1 is running-2\n"); + + return NULL; +} + +void pagefails (void) +{ + char *p; + int i; + + // ֻڴ + p = malloc(1024 * 1024); + if (p) { + // õʱͨȱҳ쳣ڴ + memset(p, 'a', 1024 * 1024); + + for (i = 0; i < 1024 * 1024; ++i) { + if (*(p + i) != 'a') { + printf("pagefails test failure."); + } + } + + free(p); + } +} + +/* + * Ƿָ쳣ں + */ +int S0102605 (void) +{ + int status = -100; + int nDelaytime = 2000; + int i = 0; + char a = 255; + char b = 255; + char c; + + // ȱҳ쳣 + pagefails(); + + // , c ϵͳӦó쳣 + c = a + b; + printf("%d\n", c); + + /* + * ʼ߳thread_attr1 + */ + pthread_attr_init(&thread_attr1); + + // thread_attr1.stackaddr = NULL; + // thread_attr1.stacksize = PTHREAD_STACK_MIN * 2; + // thread_attr1.inheritsched = PTHREAD_EXPLICIT_SCHED; + // thread_attr1.schedpolicy = SCHED_FIFO; + // thread_attr1.schedparam.sched_priority = 100; + // thread_attr1.name = "Task1"; + + status = pthread_create(&thread_id1, &thread_attr1, Fun1_security_1, NULL); + if (status == 0) { + printf( "Task1 create succesful\n"); + } else { + printf( "Task1 create Failed\n"); + return (-1); + } + + /* + * ʱ2000 TICK + */ + pthread_delay(nDelaytime); + + for (i = 0; i < 10; i++) { + printf("MainFun is running\n"); + } + + return (0); +} +/********************************************************************************************************* + * ƣ GJB_ENTRY() + * û + * + * + * ֵ + * ˵ +*********************************************************************************************************/ +int main(int argc, char **argv) +{ + int result; + + result = S0102605(); + if (result != 0) { + return (-1); + } + + return (0); +} diff --git a/security/gjb_S0102606AQ_addr_nonalign.c b/security/gjb_S0102606AQ_addr_nonalign.c new file mode 100644 index 0000000..0046816 --- /dev/null +++ b/security/gjb_S0102606AQ_addr_nonalign.c @@ -0,0 +1,120 @@ +/********************************************************************************************************* +** +** GJB ��׼���Լ� +** +** Copyright All Rights Reserved +** +**--------------�ļ���Ϣ-------------------------------------------------------------------------------- +** +** �� �� ��: gjb_S0102606AQ_addr_nonalign.c +** +** �ļ���������: 2021 �� 1 �� 12 �� +** +** �� ��: ͨ�������ַ�Ƕ����쳣��֤����ϵͳ���쳣�������� +*********************************************************************************************************/ +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif +#include +// #include "gjb.h" + +static pthread_attr_t thread_attr3; +static pthread_t thread_id3; +static int exec_flags = 0; + +void ExFunsecurity(int exc, REG_SET* reg) +{ + gjb_os_printk("excFun is running\n"); + exec_flags++; + /* + * �����쳣��, ʹPC�Ĵ���ָ����һ������ָ�� + */ + gjb_os_pc_resume(reg); + + gjb_os_printk("excFun is running over\n"); +} + + +void *Fun3_security_4 (void *arg) +{ + printf("Task3 is running-1\n"); + + /* + * �����ַ�Ƕ����쳣, ��ͬ��ƽ̨�ú�����ʵ�ֲ�ͬ + */ + gjb_os_address_noalign(); + printf("Task3 is running-2\n"); + + return NULL; +} + +//��ַ�����쳣������ں��� +int Test_S0102105AQ3 (void) +{ + int status = -100; + int nDelaytime = 2000; + int i = 0; + EXC_HANDLER old; + + /* + * ע��һ���û��쳣�������� + */ + old = exception_handler_set((EXC_HANDLER)ExFunsecurity); + + printf("exception_handler_set status = %x\n", (unsigned int)(long)old); + + //�������� + pthread_attr_init(&thread_attr3); + + thread_attr3.stackaddr = NULL; + thread_attr3.stacksize = PTHREAD_STACK_MIN * 2; + thread_attr3.inheritsched = PTHREAD_EXPLICIT_SCHED; + thread_attr3.schedpolicy = SCHED_FIFO; + thread_attr3.schedparam.sched_priority = 100; + thread_attr3.name = "Task3"; + + status = pthread_create(&thread_id3, &thread_attr3, Fun3_security_4, NULL); + if (status == 0) { + printf( "Task3 Create succesful\n"); + + } else { + printf( "Task3 Create Failed\n"); + return (-1); + } + + pthread_delay(nDelaytime); // 2000��ticks + + for (i = 0; i < 10; i++) { + printf("MainFun is running\n"); + } + + /* + * �ָ��û��쳣�������� + */ + exception_handler_set(NULL); // ֻ�ǻָ�һ��֮ǰ�Ļ��� + + if (!exec_flags) { + return (-1); + } + + return (0); +} +/********************************************************************** + * �������ƣ� GJB_ENTRY() + * ���������� �û�������� + * ��������� �� + * ��������� �� + * �� �� ֵ�� �� + * ����˵���� �� + **************************************************************************/ +int main(int argc, char **argv) +{ + int result; + + result = Test_S0102105AQ3(); /* exec test */ + if (result != 0) { + return (-1); + } + + return (0); +} diff --git a/security/gjb_S0102606AQ_addr_overflow.c b/security/gjb_S0102606AQ_addr_overflow.c new file mode 100644 index 0000000..da5100d --- /dev/null +++ b/security/gjb_S0102606AQ_addr_overflow.c @@ -0,0 +1,115 @@ +/********************************************************************************************************* +** +** GJB ׼Լ +** +** Copyright All Rights Reserved +** +**--------------ļϢ-------------------------------------------------------------------------------- +** +** : gjb_S0102606AQ_addr_overflow.c +** +** ļ: 2021 1 12 +** +** : ַ쳣, ֤ϵͳ쳣 +*********************************************************************************************************/ +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif +#include +// #include "gjb.h" + +static int exec_flags_2 = 0; +static pthread_attr_t thread_attr2; +static pthread_t thread_id2; + +void ExFunsecurity_1(int exc, REG_SET* reg) +{ + printf("excFun is running\n"); + exec_flags_2++; + gjb_os_pc_resume(reg); + + printf("excFun is running over\n"); +} + +void *Fun2security_4() +{ + printf("Task2 is running-1\n"); + + /* + * ַ쳣, ͬƽ̨úʵֲͬ + */ + gjb_array_overflow(); + printf("Task2 is running-2\n"); + + return (NULL); +} + +//ַԽ쳣ں +int Test_S0102105AQ2 (void) +{ + int status = -100; + int nDelaytime = 2000; + int i = 0; + EXC_HANDLER old; + + /* + * עһû쳣 + */ + old = exception_handler_set((EXC_HANDLER)ExFunsecurity_1); + + printf("exception_handler_set status = %x\n", (unsigned int)(long)old); + + pthread_attr_init(&thread_attr2); + + thread_attr2.stackaddr = NULL; + thread_attr2.stacksize = PTHREAD_STACK_MIN*2; + thread_attr2.inheritsched = PTHREAD_EXPLICIT_SCHED; + thread_attr2.schedpolicy = SCHED_FIFO; + thread_attr2.schedparam.sched_priority = 100; + thread_attr2.name = "Task2"; + + /* + * һ + */ + status = pthread_create(&thread_id2, &thread_attr2, Fun2security_4, NULL); + if (status == 0) { + printf( "Task2 Create seccesful\n"); + + } else { + printf( "Task2 Create Failed\n"); + return (-1); + } + + pthread_delay(nDelaytime); // 2000ticks + + for (i = 0; i < 10; i++) { + printf("MainFun is running\n"); + } + + exception_handler_set(NULL); // ֻǻָһ֮ǰĻ + + if (!exec_flags_2) { + return (-1); + } + + return (0); +} +/********************************************************************** + * ƣ GJB_ENTRY() + * û + * + * + * ֵ + * ˵ + **************************************************************************/ +int main(int argc, char **argv) +{ + int result; + + result = Test_S0102105AQ2(); /* exec test */ + if (result != 0) { + return (-1); + } + + return (0); +} diff --git a/security/gjb_S0102606AQ_illgel_code.c b/security/gjb_S0102606AQ_illgel_code.c new file mode 100644 index 0000000..62e6c48 --- /dev/null +++ b/security/gjb_S0102606AQ_illgel_code.c @@ -0,0 +1,114 @@ +/********************************************************************************************************* +** +** GJB 标准测试集 +** +** Copyright All Rights Reserved +** +**--------------文件信息-------------------------------------------------------------------------------- +** +** 文 件 名: gjb_S0102606AQ_illgel_code.c +** +** 文件创建日期: 2021 年 1 月 12 日 +** +** 描 述: 通过构造非法指令异常, 验证系统异常处理功能 +*********************************************************************************************************/ +#ifdef SYLIXOS +#define __SYLIXOS_KERNEL +#endif +#include +// #include "gjb.h" + +static int exec_flags_1 = 0; +static pthread_attr_t thread_attr1; +static pthread_t thread_id1; + +void *Fun1_security_5 (void *arg) +{ + printf("Task1 is running-1\n"); + + /* + * 构造非法指令异常, 不同的平台该函数的实现不同 + */ + gjb_os_illeagal_code(); + + printf("Task1 is running-2\n"); + + return NULL; +} + +void ExFunxxxx(int exc, REG_SET* reg) +{ + printf("excFun is running\n"); + exec_flags_1++; + gjb_os_pc_resume(reg); + + printf("excFun is running over\n"); +} + +//非法指令异常测试入口函数 +int Test_S0102105AQ1 (void) +{ + int status = -100; + int nDelaytime = 2000; + int i = 0; + EXC_HANDLER old_exc; + + /* + * 注册一个用户异常处理函数 + */ + old_exc = exception_handler_set((EXC_HANDLER)ExFunxxxx); + + printf("exception_handler_set status = %x\n", (unsigned int)(long)old_exc); + + //创建任务 + pthread_attr_init(&thread_attr1); + + thread_attr1.stackaddr = NULL; + thread_attr1.stacksize = PTHREAD_STACK_MIN * 2; + thread_attr1.inheritsched = PTHREAD_EXPLICIT_SCHED; + thread_attr1.schedpolicy = SCHED_FIFO; + thread_attr1.schedparam.sched_priority = 100; + thread_attr1.name = "Task1"; + + status = pthread_create(&thread_id1, &thread_attr1, Fun1_security_5, NULL); + if (status == 0) { + printf( "Task1 create succesful\n"); + + } else { + printf( "Task1 create Failed\n"); + return (-1); + } + + pthread_delay(nDelaytime); //2000个ticks + + for (i = 0; i < 10; i++) { + printf("MainFun is running\n"); + } + + exception_handler_set(NULL); // 只是恢复一下之前的环境 + + if (!exec_flags_1) { + return (-1); + } + + return (0); +} +/********************************************************************** + * 函数名称: GJB_ENTRY() + * 功能描述: 用户程序入口 + * 输入参数: 无 + * 输出参数: 无 + * 返 回 值: 无 + * 其它说明: 无 + **************************************************************************/ +int main(int argc, char **argv) +{ + int result; + + result = Test_S0102105AQ1(); /* exec test */ + if (result != 0) { + return (-1); + } + + return (0); +} -- Gitee