mtxlib.gms : 뮤텍스 라이브러리의 기본 테스트

설명

기고자: Clemens Westphal, 2015년 11월

소형 모델 유형 :메가 슬롯


카테고리 : 메가 슬롯 테스트 라이브러리


메인 파일 : mtxlib.gms

$title '뮤텍스 라이브러리의 기본 테스트' (MTXLIB,SEQ=689)

$onText
기고자: Clemens Westphal, 2015년 11월
$offText

$call rm -f 중요한.txt

*임의의 뮤텍스 ID 생성
$eval mtxID round(frac(jnow)*24*60*60*1000)

$onEcho > create.gms
$funcLibIn mtxlib mtxcclib
함수 만들기 / mtxlib.Create /;
abort$Create(%mtxID%) '뮤텍스 생성 문제';
$offEcho
$call.checkErrorLevel 메가 슬롯 create.gms lo=2

$onEcho > client.gms
$funcLibIn mtxlib mtxcclib
기능 잠금 / mtxlib.Lock /
         잠금 해제 / mtxlib.Unlock /;

스칼라 s;
s = 잠금(%mtxID%);
파일 f /'중요.txt'/;
f.ap=1;
f를 넣어;
put "client%number%: a" /;
닫다;
s = 수면(1);
f를 넣어;
put "client%number%: b" /;
닫다;
s = 수면(1);
f를 넣어;
put "client%number%: c" /;
닫다;
s = 잠금 해제(%mtxID%);
$offEcho

$call.Async 게임 client.gms --number=1 lo=2 lf=log1.txt
$eval jh JobHandle
$call.checkErrorLevel 메가 슬롯 client.gms --number=2 lo=2 lf=log2.txt

$라벨 l1
$평가 x 수면(1)
$평가 상태 JobStatus(%jh%)
$if %status% == 1 $goTo l1

$onEcho >ticalExpected1.txt
클라이언트1:
클라이언트1: b
클라이언트1: c
클라이언트2:
클라이언트2: b
클라이언트2: c
$offEcho

$onEcho >ticalExpected2.txt
클라이언트2:
클라이언트2: b
클라이언트2: c
클라이언트1:
클라이언트1: b
클라이언트1: c
$offEcho

$onEcho > delete.gms
$funcLibIn mtxlib mtxcclib
기능 삭제 / mtxlib.Delete /;
abort$Delete(%mtxID%) '뮤텍스 삭제 문제';
$offEcho
$call.checkErrorLevel 메가 슬롯 delete.gms lo=2

$call diff importantExpected1.txt important.txt > %system.nullfile%
$if errorlevel 1 $call diff importantExpected2.txt important.txt > %system.nullfile%
$if errorlevel 1 $abort '중요한.txt가 예상과 다릅니다.'

$call rm -f important.txt