mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
76 lines
3.1 KiB
ObjectPascal
76 lines
3.1 KiB
ObjectPascal
{
|
|
Copyright (C)
|
|
2026 - Uladzimir Karpenka, EW8BAK
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
}
|
|
|
|
program winprobe;
|
|
|
|
{
|
|
Прогон WINDOWS-ветки SerialPort.pas на Linux.
|
|
|
|
★Компиляции мало. Соседняя проверка (-Cn) ловит синтаксис и разрешение имён,
|
|
но не поведение, а под Windows у обёртки своя логика: перевод нулевого хендла
|
|
RTL в SER_INVALID_HANDLE и свой ответ SerValid (ядро Windows нулевой хендл не
|
|
выдаёт никогда, значит ноль там негоден — в отличие от Unix, где это законный
|
|
дескриптор при закрытом стандартном вводе). Всё это чистая логика поверх
|
|
заглушки модуля Serial, поэтому её можно и нужно прогнать здесь.
|
|
}
|
|
|
|
{$MODE Delphi}
|
|
|
|
uses
|
|
SysUtils, SerialPort;
|
|
|
|
var
|
|
Passed, Failed: Integer;
|
|
|
|
procedure Check(const Name: string; Cond: Boolean; const Extra: string = '');
|
|
begin
|
|
if Cond then
|
|
begin
|
|
Inc(Passed);
|
|
WriteLn(' ok ', Name);
|
|
end
|
|
else
|
|
begin
|
|
Inc(Failed);
|
|
if Extra <> '' then WriteLn(' FAIL ', Name, ' ', Extra)
|
|
else WriteLn(' FAIL ', Name);
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
Passed := 0;
|
|
Failed := 0;
|
|
WriteLn(' -- прогон WINDOWS-ветки SerialPort на заглушке');
|
|
|
|
// Заглушка Serial.SerOpen всегда отдаёт ноль — то есть «не открылось» по
|
|
// соглашению RTL под Windows. Обёртка обязана перевести это в свой признак.
|
|
Check('★отказ RTL (ноль) переводится в SER_INVALID_HANDLE',
|
|
SerOpen('COM1') = SER_INVALID_HANDLE, IntToStr(SerOpen('COM1')));
|
|
Check('★нулевой хендл под Windows негоден', not SerValid(0));
|
|
Check('SER_INVALID_HANDLE негоден', not SerValid(SER_INVALID_HANDLE));
|
|
Check('обычный хендл годен', SerValid(5));
|
|
|
|
Check('COM1 остаётся коротким', SerWinDeviceName('COM1') = 'COM1');
|
|
Check('COM10 получает префикс', SerWinDeviceName('COM10') = '\\.\COM10');
|
|
|
|
WriteLn(Format(' -- ветка windows: %d проверок, провалено %d',
|
|
[Passed + Failed, Failed]));
|
|
if Failed > 0 then Halt(1);
|
|
end.
|