1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 08:13:30 +00:00

Updated self test, and fixed Zenity issue with UTF8

This commit is contained in:
Bryan Roe
2022-05-25 10:54:24 -07:00
parent b34fa668d1
commit f6f66a0189
3 changed files with 59 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@@ -919,6 +919,7 @@ function testFileDownload()
{ {
this.end(); this.end();
this.ret._rej(' -> File Transfer (Download).........[CRC FAILED]'); this.ret._rej(' -> File Transfer (Download).........[CRC FAILED]');
console.log(' -> CRC=' + this.crc + ' , expected: ' + global.testbufferCRC);
} }
} }
} }

View File

@@ -400,7 +400,6 @@ function linux_messageBox()
parms.push('--text=' + caption); parms.push('--text=' + caption);
parms.push('--no-wrap'); parms.push('--no-wrap');
if (this.zenity.timeout) { parms.push('--timeout=' + timeout); } if (this.zenity.timeout) { parms.push('--timeout=' + timeout); }
ret.child = require('child_process').execFile(this.zenity.path, parms, { uid: uid, env: { XAUTHORITY: xinfo.xauthority ? xinfo.xauthority : "", DISPLAY: xinfo.display } }); ret.child = require('child_process').execFile(this.zenity.path, parms, { uid: uid, env: { XAUTHORITY: xinfo.xauthority ? xinfo.xauthority : "", DISPLAY: xinfo.display } });
if (this.zenity.timeout) if (this.zenity.timeout)
{ {
@@ -419,24 +418,27 @@ function linux_messageBox()
ret.child.on('exit', function (code) ret.child.on('exit', function (code)
{ {
if (this.timeout) { clearTimeout(this.timeout); } if (this.timeout) { clearTimeout(this.timeout); }
if (Array.isArray(this.promise._options.layout)) if (!(this.stderr.str.includes('option is not') && this.promise._options.zenity.timeout))
{ {
if (code == 0 && ((process.platform == 'freebsd' && this.stdout.ostr.trim() == '') || process.platform != 'freebsd')) if (Array.isArray(this.promise._options.layout))
{ {
this.promise._res(this.promise._options.layout[0]); if (code == 0 && ((process.platform == 'freebsd' && this.stdout.ostr.trim() == '') || process.platform != 'freebsd'))
}
else
{
var val = this.stdout.ostr.trim();
for (var i = 1; i < this.promise._options.layout.length; ++i)
{ {
if (this.promise._options.layout[i] == val) this.promise._res(this.promise._options.layout[0]);
{ }
this.promise._res(val); else
return; {
} var val = this.stdout.ostr.trim();
for (var i = 1; i < this.promise._options.layout.length; ++i)
{
if (this.promise._options.layout[i] == val)
{
this.promise._res(val);
return;
}
}
this.promise._rej('timeout');
} }
this.promise._rej('timeout');
} }
} }
switch (code) switch (code)
@@ -458,16 +460,55 @@ function linux_messageBox()
this.promise._ch.stdout.str = ''; this.promise._ch.stdout.on('data', function (c) this.promise._ch.stdout.str = ''; this.promise._ch.stdout.on('data', function (c)
{ {
this.str += c.toString(); this.str += c.toString();
if (Array.isArray(layout))
{
var i;
var tmp = c.toString().trim();
for (i = 0; i < layout.length; ++i)
{
if(layout[i] == tmp)
{
this.parent.result = tmp;
//this.parent.promise._res(tmp);
return;
}
}
}
if (this.str.includes('<<<<$_RESULT>>>>')) { this.str = this.str.split('<<<<$_RESULT>>>>')[1]; } if (this.str.includes('<<<<$_RESULT>>>>')) { this.str = this.str.split('<<<<$_RESULT>>>>')[1]; }
if (this.str.includes('>>>>')) { this.parent.kill(); } if (this.str.includes('>>>>')) { this.parent.kill(); }
}); });
this.promise._ch.stdin.write('su - ' + uname + '\n'); this.promise._ch.stdin.write('su - ' + uname + '\n');
this.promise._ch.stdin.write('export DISPLAY=' + xinfo.display + '\n'); this.promise._ch.stdin.write('export DISPLAY=' + xinfo.display + '\n');
this.promise._ch.stdin.write('zenity ' + (this.promise._options.layout == null ? '--question' : '--warning')); this.promise._ch.stdin.write('zenity ');
if (Array.isArray(layout))
{
var i;
this.promise._ch.stdin.write('--info');
for (i = 0; i < layout.length; ++i)
{
if (i == 0)
{
this.promise._ch.stdin.write(' --ok-label=' + layout[i]);
}
else
{
this.promise._ch.stdin.write(' --extra-button=' + layout[i]);
}
}
}
else
{
this.promise._ch.stdin.write((this.promise._options.layout == null ? '--question' : '--warning'));
}
this.promise._ch.stdin.write(' --title=' + this.promise._options.title + ' --text=' + this.promise._options.caption); this.promise._ch.stdin.write(' --title=' + this.promise._options.title + ' --text=' + this.promise._options.caption);
this.promise._ch.stdin.write(' --timeout=' + this.promise._options.timeout + '\nexport _RESULT=$?\necho "<<<<$_RESULT>>>>"\nexit'); this.promise._ch.stdin.write(' --timeout=' + this.promise._options.timeout + '\nexport _RESULT=$?\necho "<<<<$_RESULT>>>>"\nexit');
this.promise._ch.on('exit', function () this.promise._ch.on('exit', function ()
{ {
if (this.result != null)
{
this.promise._res(this.result);
return;
}
var res = this.stdout.str.split('>>>>')[0].split('<<<<')[1]; var res = this.stdout.str.split('>>>>')[0].split('<<<<')[1];
switch(parseInt(res)) switch(parseInt(res))
{ {