brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · c59f339 Raw
54 lines · cpp
1//===- CommandTest.cpp -- command line runtime builder unit tests ---------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "flang/Optimizer/Builder/Runtime/Command.h"10#include "RuntimeCallTestBase.h"11#include "gtest/gtest.h"12 13TEST_F(RuntimeCallTest, genCommandArgumentCountTest) {14  mlir::Location loc = firBuilder->getUnknownLoc();15  mlir::Value result = fir::runtime::genCommandArgumentCount(*firBuilder, loc);16  checkCallOp(result.getDefiningOp(), "_FortranAArgumentCount", /*nbArgs=*/0,17      /*addLocArgs=*/false);18}19 20TEST_F(RuntimeCallTest, genGetCommandArgument) {21  mlir::Location loc = firBuilder->getUnknownLoc();22  mlir::Type intTy = firBuilder->getDefaultIntegerType();23  mlir::Type boxTy = fir::BoxType::get(firBuilder->getNoneType());24  mlir::Value number = fir::UndefOp::create(*firBuilder, loc, intTy);25  mlir::Value value = fir::UndefOp::create(*firBuilder, loc, boxTy);26  mlir::Value length = fir::UndefOp::create(*firBuilder, loc, boxTy);27  mlir::Value errmsg = fir::UndefOp::create(*firBuilder, loc, boxTy);28  mlir::Value result = fir::runtime::genGetCommandArgument(29      *firBuilder, loc, number, value, length, errmsg);30  checkCallOp(result.getDefiningOp(), "_FortranAGetCommandArgument",31      /*nbArgs=*/4,32      /*addLocArgs=*/true);33}34 35TEST_F(RuntimeCallTest, genGetEnvVariable) {36  mlir::Location loc = firBuilder->getUnknownLoc();37  mlir::Value name = fir::UndefOp::create(*firBuilder, loc, boxTy);38  mlir::Value value = fir::UndefOp::create(*firBuilder, loc, boxTy);39  mlir::Value length = fir::UndefOp::create(*firBuilder, loc, boxTy);40  mlir::Value trimName = fir::UndefOp::create(*firBuilder, loc, i1Ty);41  mlir::Value errmsg = fir::UndefOp::create(*firBuilder, loc, boxTy);42  mlir::Value result = fir::runtime::genGetEnvVariable(43      *firBuilder, loc, name, value, length, trimName, errmsg);44  checkCallOp(result.getDefiningOp(), "_FortranAGetEnvVariable", /*nbArgs=*/5,45      /*addLocArgs=*/true);46}47 48TEST_F(RuntimeCallTest, genGetPID) {49  mlir::Location loc = firBuilder->getUnknownLoc();50  mlir::Value result = fir::runtime::genGetPID(*firBuilder, loc);51  checkCallOp(result.getDefiningOp(), "_FortranAGetPID", /*nbArgs=*/0,52      /*addLocArgs=*/false);53}54