test: Add test programs for #1166
refs: #1166 Change-Id: I9b6dd8628e8a3dcb2281e31f4b8d116e9c7852d8
This commit is contained in:
97
test/issues/1166/CT1166.c
Normal file
97
test/issues/1166/CT1166.c
Normal file
@ -0,0 +1,97 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int *p2;
|
||||
pid_t pid;
|
||||
int st;
|
||||
int ok = 0;
|
||||
int ng = 0;
|
||||
|
||||
printf("CT1166 START\n");
|
||||
|
||||
fd = open("/dev/fb0", O_RDWR, 0);
|
||||
if (fd == -1) {
|
||||
printf("CT1166T01 could not open /dev/fb0: %s\n",
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
printf("CT1166T01: OK open(/dev/fb0)\n");
|
||||
|
||||
p2 = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
if (p2 == (void *)-1) {
|
||||
printf("CT1166T02: NG could not mmap: %s\n", strerror(errno));
|
||||
ng++;
|
||||
exit(1);
|
||||
}
|
||||
printf("CT1166T02: OK mmap(MAP_PRIVATE)\n");
|
||||
ok++;
|
||||
close(fd);
|
||||
|
||||
p2[0] = 50;
|
||||
printf("CT1166T03: OK store private fb0\n");
|
||||
ok++;
|
||||
if (p2[0] == 50) {
|
||||
printf("CT1166T04: OK load private fb0\n");
|
||||
ok++;
|
||||
}
|
||||
else {
|
||||
printf("CT1166T04: NG load private fb0\n");
|
||||
ng++;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
printf("CT1166T05: NG could not fork: %s\n", strerror(errno));
|
||||
ng++;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
printf("CT1166T05: OK fork\n");
|
||||
ok++;
|
||||
|
||||
p2[0] = 10;
|
||||
printf("CT1166T06: OK store private fb0 by child\n");
|
||||
ok++;
|
||||
if (p2[0] == 10) {
|
||||
printf("CT1166T07: OK load private fb0 by child\n");
|
||||
ok++;
|
||||
}
|
||||
else {
|
||||
printf("CT1166T07: NG load private fb0 by child\n");
|
||||
ng++;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
while (waitpid(pid, &st, 0) == -1 && errno == EINTR)
|
||||
;
|
||||
|
||||
if (p2[0] == 50) {
|
||||
printf("CT1166T08: OK private fb0 do not updated\n");
|
||||
ok++;
|
||||
}
|
||||
else {
|
||||
printf("CT1166T08: NG private fb0 updated %d\n", p2[0]);
|
||||
ng++;
|
||||
}
|
||||
if (ng == 0) {
|
||||
printf("CT1166 all tests are OK\n");
|
||||
}
|
||||
else {
|
||||
printf("CT1166 OK=%d NG=%d\n", ok, ng);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
9
test/issues/1166/CT1166.sh
Normal file
9
test/issues/1166/CT1166.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
USELTP=0
|
||||
USEOSTEST=0
|
||||
|
||||
BOOTPARAM="-c 1-3 -m 1G"
|
||||
. ../../common.sh
|
||||
|
||||
################################################################################
|
||||
$MCEXEC ./CT1166
|
||||
19
test/issues/1166/CT1166.txt
Normal file
19
test/issues/1166/CT1166.txt
Normal file
@ -0,0 +1,19 @@
|
||||
Script started on Mon Jan 7 16:10:54 2019
|
||||
[sira@localhost 1166]$ make test
|
||||
sh ./CT1166.sh
|
||||
mcstop+release.sh ... done
|
||||
mcreboot.sh -c 1-3 -m 1G ... done
|
||||
CT1166 START
|
||||
CT1166T01: OK open(/dev/fb0)
|
||||
CT1166T02: OK mmap(MAP_PRIVATE)
|
||||
CT1166T03: OK store private fb0
|
||||
CT1166T04: OK load private fb0
|
||||
CT1166T05: OK fork
|
||||
CT1166T06: OK store private fb0 by child
|
||||
CT1166T07: OK load private fb0 by child
|
||||
CT1166T08: OK private fb0 do not updated
|
||||
CT1166 all tests are OK
|
||||
[sira@localhost 1166]$ exit
|
||||
exit
|
||||
|
||||
Script done on Mon Jan 7 16:11:05 2019
|
||||
13
test/issues/1166/Makefile
Normal file
13
test/issues/1166/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
CC = gcc
|
||||
TARGET = CT1166
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
C1009T01: CT1166.c
|
||||
$(CC) -g -Wall -o $@ $^
|
||||
|
||||
test:: all
|
||||
sh ./CT1166.sh
|
||||
|
||||
clean::
|
||||
rm -f $(TARGET) *.o
|
||||
32
test/issues/1166/README
Normal file
32
test/issues/1166/README
Normal file
@ -0,0 +1,32 @@
|
||||
【Issue#1166 動作確認】
|
||||
□ テスト内容
|
||||
調査の結果、Issue#1166 の指摘は本来発生しない現象なことが判明したため、
|
||||
プログラムの変更は行わなかった。
|
||||
|
||||
Issue#1166 の指摘の状況を起こすプログラムを実行し、Linux と同様の結果に
|
||||
なることを確認する。
|
||||
|
||||
CT1166T01 /dev/fb0 をオープンできる
|
||||
CT1166T02 /dev/fb0 を mmap を使って仮想空間にマップできる
|
||||
CT1166T03 マップした領域に書き込みできる
|
||||
CT1166T04 マップした領域に書き込んだデータを読み込むことができる
|
||||
CT1166T05 fork できる (指摘では、fork が失敗しなければならない)
|
||||
CT1166T06 子プロセス側で親プロセスがマップした領域に書き込みできる
|
||||
CT1166T07 子プロセス側で親プロセスがマップした領域に書き込んだデータを読める
|
||||
CT1166T08 CT1166T06 の子プロセスの書き込みが親プロセスのマップ領域に影響
|
||||
しない (親プロセスでは CT1166T03 のデータが参照されることを確認)
|
||||
|
||||
□ 実行手順
|
||||
$ make test
|
||||
|
||||
□ 実行結果
|
||||
CT1166.txt 参照。
|
||||
全ての項目が OK となっていることを確認。
|
||||
|
||||
□ 注意
|
||||
1. テストを実行するユーザは /dev/fb0 に書き込み可能であること。
|
||||
即ち、video グループに属すか、特権ユーザである必要がある。
|
||||
2. wallabyのビデオデバイス(MATROX G200系)など、幾つかのデバイスは mmap に対応
|
||||
していないため、CT1166T02 で NG になる。これは Linux も同様である。
|
||||
このため、Linux で OK となる環境で実行すること。
|
||||
例えば VMWare 環境では実行可能である。
|
||||
Reference in New Issue
Block a user