11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (common.isWindows) { 61cb0ef41Sopenharmony_ci assert.strictEqual(process.setgroups, undefined); 71cb0ef41Sopenharmony_ci return; 81cb0ef41Sopenharmony_ci} 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciif (!common.isMainThread) 111cb0ef41Sopenharmony_ci return; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciassert.throws( 141cb0ef41Sopenharmony_ci () => { 151cb0ef41Sopenharmony_ci process.setgroups(); 161cb0ef41Sopenharmony_ci }, 171cb0ef41Sopenharmony_ci { 181cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 191cb0ef41Sopenharmony_ci name: 'TypeError', 201cb0ef41Sopenharmony_ci message: 'The "groups" argument must be an instance of Array. ' + 211cb0ef41Sopenharmony_ci 'Received undefined' 221cb0ef41Sopenharmony_ci } 231cb0ef41Sopenharmony_ci); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciassert.throws( 261cb0ef41Sopenharmony_ci () => { 271cb0ef41Sopenharmony_ci process.setgroups([1, -1]); 281cb0ef41Sopenharmony_ci }, 291cb0ef41Sopenharmony_ci { 301cb0ef41Sopenharmony_ci code: 'ERR_OUT_OF_RANGE', 311cb0ef41Sopenharmony_ci name: 'RangeError', 321cb0ef41Sopenharmony_ci } 331cb0ef41Sopenharmony_ci); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci[undefined, null, true, {}, [], () => {}].forEach((val) => { 361cb0ef41Sopenharmony_ci assert.throws( 371cb0ef41Sopenharmony_ci () => { 381cb0ef41Sopenharmony_ci process.setgroups([val]); 391cb0ef41Sopenharmony_ci }, 401cb0ef41Sopenharmony_ci { 411cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 421cb0ef41Sopenharmony_ci name: 'TypeError', 431cb0ef41Sopenharmony_ci message: 'The "groups[0]" argument must be ' + 441cb0ef41Sopenharmony_ci 'one of type number or string.' + 451cb0ef41Sopenharmony_ci common.invalidArgTypeHelper(val) 461cb0ef41Sopenharmony_ci } 471cb0ef41Sopenharmony_ci ); 481cb0ef41Sopenharmony_ci}); 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ciassert.throws(() => { 511cb0ef41Sopenharmony_ci process.setgroups([1, 'fhqwhgadshgnsdhjsdbkhsdabkfabkveyb']); 521cb0ef41Sopenharmony_ci}, { 531cb0ef41Sopenharmony_ci code: 'ERR_UNKNOWN_CREDENTIAL', 541cb0ef41Sopenharmony_ci message: 'Group identifier does not exist: fhqwhgadshgnsdhjsdbkhsdabkfabkveyb' 551cb0ef41Sopenharmony_ci}); 56