Skip to content

Commit

Permalink
Dummy functions
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Zeithaml <[email protected]>
  • Loading branch information
Martin-Zeithaml committed Sep 24, 2024
1 parent 07be5fb commit 0cccad5
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
41 changes: 39 additions & 2 deletions tests/quickJS/lib/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,43 @@
// Copyright Contributors to the Zowe Project.
*/

export function clog(condition, msg) {
console.log(`${condition ? '' : '== ERROR ==> '}${msg}`);
export const RED = "\u001b[31m";
export const GREEN = "\u001b[32m";
export const YELLOW = "\u001b[33m";
export const PURPLE = "\u001b[35m";
export const CYAN = "\u001b[36m";
export const RESET = "\u001b[0m";

export function color(color, msg) {
console.log(`${color}${msg}${RESET}`);
}

export function red(msg) {
color(RED, msg);
}

export function green(msg) {
color(GREEN, msg);
}

export function yellow(msg) {
color(YELLOW, msg);
}

export function purple(msg) {
color(PURPLE, msg);
}

export function cyan(msg) {
color(CYAN, msg);
}

export function conditionally(condition, ...msg) {
console.log(`${condition ? GREEN : RED}` + msg + RESET);
}

export function lines(clr, msg) {
color(clr, `\n${'-'.repeat(msg.length)}`);
color(clr, `${msg}`);
color(clr, `${'-'.repeat(msg.length)}\n`);
}
5 changes: 3 additions & 2 deletions tests/quickJS/quickJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import * as std from 'cm_std';
import * as print from './lib/print';
import * as testZos from './testLib/testZos';

const TEST_ZOS = [
Expand Down Expand Up @@ -39,9 +40,9 @@ for (let testFunction in TESTS) {
}

if (errors) {
console.log(`\n${errors} error${errors == 1 ? '' : 's'} detected in ${total} tests, review the test output.\n`);
print.lines(print.RED, `${errors} error${errors == 1 ? '' : 's'} detected in ${total} tests, review the test output.`);
std.exit(8);
} else {
console.log(`\n${total} tests succesfull.\n`);
print.lines(print.GREEN, `${total} tests succesfull.`);
std.exit(0);
}
31 changes: 22 additions & 9 deletions tests/quickJS/testLib/testZos.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,41 @@ import * as zos from 'zos';
import * as print from '../lib/print';


// int status = tagFile(pathname, ccsid);
export function test_changeTag() {
const result = zos.changeTag('./');
print.purple(`DUMMY TEST: zos.changeTag(./)=${result}`);
return { errors: 0, total: 0 }
}


// int status = changeExtendedAttributes(pathname, extattr, onOffInt ? true : false);
export function test_changeExtAttr() {
const result = zos.changeExtAttr('./');
print.purple(`DUMMY TEST: zos.changeExtAttr(./)=${result}`);
return { errors: 0, total: 0 }
}


// int status = convertOpenStream(fd, ccsid);
export function test_changeStreamCCSID() {
const result = zos.changeStreamCCSID('./');
print.purple(`DUMMY TEST: zos.changeStreamCCSID(./)=${result}`);
return { errors: 0, total: 0 }
}


// res = stat(pathNative, &st);
export function test_zstat() {
const result = zos.zstat('./testLib/testZos.js');
print.purple(`DUMMY TEST: zos.zstat(./testLib/testZos.js)=${JSON.stringify(result)}`);
return { errors: 0, total: 0 }
}


export function test_getZosVersion() {
const result = zos.getZosVersion();
print.clog(true, `zos.getZosVersion()=${result}${result > 0 ? ` --hex--> 0x${result.toString(16)}` : ``}`);
print.conditionally(true, `zos.getZosVersion()=${result}${result > 0 ? `=hex(0x${result.toString(16)}` : ``})`);
return { errors: result ? 0 : 1, total : 1 };
}

Expand All @@ -45,16 +57,18 @@ export function test_getEsm() {
const result = zos.getEsm();

if (result == null || !EXPECTED.includes(result)) {
print.clog(false, `zos.getEsms()=${result}`);
print.conditionally(false, `zos.getEsms()=${result}`);
return { errors: 1, total: 1 };
}
print.clog(true, `zos.getEsms()=${result}`);
print.conditionally(true, `zos.getEsms()=${result}`);
return { errors: 0, total: 1 };
}



export function test_dslist() {
const result = zos.dslist('SYS1.MACLIB');
print.purple(`DUMMY TEST: zos.zstat(SYS1.MACLIB)=${JSON.stringify(result)}`);
return { errors: 0, total: 0 }
}

Expand All @@ -65,20 +79,19 @@ export function test_resolveSymbol() {
const yymmdd = (date.getFullYear() - 2000) * 10000 + (date.getMonth() + 1) * 100 + date.getDate() + '';
let errs = 0;

print.clog(result == yymmdd, `zos.resolveSymbol('&YYMMDD')=${result} -> ${yymmdd}`);
print.conditionally(result == yymmdd, `zos.resolveSymbol('&YYMMDD')=${result} -> ${yymmdd}`);
if (result != yymmdd) {
errs ++
}

const SYMBOLS_ERR = [ undefined, null, '', 'YYMMDD', ' &', ['a', 'b'], '& UNDEFINED SYMBOL !@#$%^&*()' ];
for (let s in SYMBOLS_ERR) {
const result = zos.resolveSymbol(SYMBOLS_ERR[s]);
print.clog(result.length == 0, `zos.resolveSymbol(${SYMBOLS_ERR[s]})=${result}`);
print.conditionally(result.length == 0, `zos.resolveSymbol(${SYMBOLS_ERR[s]})=${result}`);
if (result.length) {
errs++
}
}

return { errors: errs, total : SYMBOLS_ERR.length + 1 };;
}

Expand All @@ -90,18 +103,18 @@ export function test_getStatvfs() {

for (let p in PATHS_OK) {
const result = zos.getStatvfs(PATHS_OK[p]);
print.clog(result[1] == 0, `zos.getStatvfs(${PATHS_OK[p]})=${result[1]}`);
print.conditionally(result[1] == 0, `zos.getStatvfs(${PATHS_OK[p]})=${result[1]}`);
if (result[1] != 0) {
errs++;
}
if (result[0]) {
console.log(` stats=${JSON.stringify(result[0])}`);
console.log(`Stats=${JSON.stringify(result[0])}`);
}
}

for (let p in PATHS_ERR) {
const result = zos.getStatvfs(PATHS_ERR[p]);
print.clog(result[1] != 0, `zos.getStatvfs(${PATHS_ERR[p]})=${result[1]}`);
print.conditionally(result[1] != 0, `zos.getStatvfs(${PATHS_ERR[p]})=${result[1]}`);
if (result[1] == 0) {
errs++;
}
Expand Down

0 comments on commit 0cccad5

Please sign in to comment.