Gem5: No workload specified - gem5

I am having some trouble running the simulation in gem5. I keep getting
no workload specified
# Set the workload and benchmark
process = Process()
process.cmd = ['gzip', '-k', 'test.txt']
system.cpu.workload = process
system.cpu.createThreads()
# Set the workload
print("set workload")
m5.command_line.set_workload('mcf')
print("workload Set")
I tried to print the workload portion but received the same error
# Set the workload
print("set workload")
m5.command_line.set_workload('mcf')
print("workload Set")

If none of the below code works with you, leave a comment and I will share more a complete gem5 project to run SPEC17 and SEC06 besides executable bins.
Here is an example to run one of the SEC17 benchmarks:
bwaves_s = Process()
bwaves_s_dir = '603.bwaves_s/'
bwaves_s_run_dir = bwaves_s_dir + refspeed_run_dir
bwaves_s.executable = bench_dir + bwaves_s_run_dir + 'speed_bwaves' +
exe_suffix
bwaves_s_data = 'bwaves_1.in'
bwaves_s.cmd = [bwaves_s.executable]
bwaves_s.output = 'bwaves_s.out'
bwaves_s.input = bench_dir + bwaves_s_run_dir + bwaves_s_data
system.cpu[0].workload = spec_process "OR" system.cpu.workload =
spec_process
Another example to run a binary
from gem5.components.boards.simple_board import SimpleBoard
from gem5.components.memory.single_channel import SingleChannelDDR3_1600
from gem5.components.processors.simple_processor import SimpleProcessor
from gem5.components.processors.cpu_types import CPUTypes
from gem5.resources.resource import CustomResource
from gem5.simulate.simulator import Simulator
from unique_cache_hierarchy.unique_cache_hierarchy_complete import UniqueCacheHierarchy
Obtain the components.
cache_hierarchy = UniqueCacheHierarchy()
memory = SingleChannelDDR3_1600("1GiB")
processor = SimpleProcessor(cpu_type=CPUTypes.ATOMIC, num_cores=1)
Add them to the board.
board = SimpleBoard(
clk_freq="3GHz", processor=processor, memory=memory, cache_hierarchy=cache_hierarchy
)
Set the workload.
binary = CustomResource(
"materials/using-gem5/02-stdlib/m5-exit-example/m5-exit-example"
)
board.set_se_binary_workload(binary)
Setup the Simulator and run the simulation.
simulator = Simulator(board=board)
simulator.run()

Related

How I can save multiple screenshots when the test is fail

I use selenium with pytest to do some automation testing and I use a fixture to take a screenshot when it fails here is the code for the fixture:
timestamp = datetime.now().strftime('%H-%M-%S')
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
extra = getattr(report, 'extra', [])
if report.when == 'call':
# always add url to report
# extra.append(pytest_html.extras.url('E:\Python Projects\StackField\screenshot'))
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
feature_request = item.funcargs["request"]
driver = feature_request.getfixturevalue("setup")
img_name = "name.png"
img_path = os.path.join("E:\Python Projects\StackField\screenshot", img_name)
driver.save_screenshot(img_path)
# extra.append(pytest_html.extras.image('E:\Python Projects\StackField\screenshot' + timestamp + '.png'))
if (report.skipped and xfail) or (report.failed and not xfail):
# only add additional html on failure
extra.append(pytest_html.extras.image(img_path))
extra.append(pytest_html.extras.html('<div>Additional HTML</div>'))
report.extra = extra
And I got an issue when more than 1 test is failed the same screenshot is added to the report my next question is how can I add more than 1 screenshot inside?
Thank you in advance!
Seems you save all screenshots with the same name.
Try to set the unique name for the screenshot:
from random import randrange
if (report.skipped and xfail) or (report.failed and not xfail):
feature_request = item.funcargs["request"]
driver = feature_request.getfixturevalue("setup")
timestamp = datetime.now().strftime('%H-%M-%S')
img_name = "name" + timestamp + ".png"
# (even better also add some random number in advance "name" + timestamp + randrange(100) + ".png"
img_path = os.path.join("E:\Python Projects\StackField\screenshot", img_name)
driver.save_screenshot(img_path)

How to loop inside a custom Telegram bot?

We are trying to make a telegram price bot but running into an issue that could be solved using third party code, however we can't set the bot to send us the updated price every 5 minutes (or more) WITHOUT USING THIRD PARTY SOLUTIONS for security reasons.
How to loop from INSIDE this code, without using another third party Telegram bot?
Here is the code
import telegram
from telegram.ext import Updater
from telegram.ext import CommandHandler
from tracker import get_prices
telegram_bot_token = "mybot"
updater = Updater(token=telegram_bot_token, use_context=True)
dispatcher = updater.dispatcher
def start(update, context):
chat_id = update.effective_chat.id
message = ""
crypto_data = get_prices()
for i in crypto_data:
coin = crypto_data[i]["coin"]
price = crypto_data[i]["price"]
change_day = crypto_data[i]["change_day"]
change_hour = crypto_data[i]["change_hour"]
message += f" {coin}={price:,.5f}$ \nHour Change: {change_hour:.3f}%\nDay Change: {change_day:.3f}%\n\n"
context.bot.send_message(chat_id=chat_id, text=message)
dispatcher.add_handler(CommandHandler("start", start))
updater.start_polling()
Any solution that correctly sends one message at a time without appending to the previous one? Thanks!
There are different ways to do this.
The first would be with a simple time.sleep() in a while loop:
import time
def start(update, context):
chat_id = update.effective_chat.id
while True:
message = ""
crypto_data = get_prices()
for i in crypto_data:
coin = crypto_data[i]["coin"]
price = crypto_data[i]["price"]
change_day = crypto_data[i]["change_day"]
change_hour = crypto_data[i]["change_hour"]
message += f" {coin}={price:,.5f}$ \nHour Change:{change_hour:.3f}%\nDay Change: {change_day:.3f}%\n\n"
context.bot.send_message(chat_id=chat_id, text=message)
time.sleep(300)
Another method might be using a background process scheduler, but you would probably refactor your start function and only schedule the part that creates/sends the message. (The part inside the while loop)
Advanced Python Scheduler (pip install apscheduler) is a fantastic library for this, but it is a third party library, so maybe not appropriate for you. I have used it on many projects however.
EDIT:
Here's an example of scheduling with apscheduler:
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
def message_loop(chat_id, bot):
message = ""
crypto_data = get_prices()
for i in crypto_data:
coin = crypto_data[i]["coin"]
price = crypto_data[i]["price"]
change_day = crypto_data[i]["change_day"]
change_hour = crypto_data[i]["change_hour"]
message += f" {coin}={price:,.5f}$ \nHour Change: {change_hour:.3f}%\nDay Change: {change_day:.3f}%\n\n"
bot.send_message(chat_id=chat_id, text=message)
def start(update, context):
chat_id = update.effective_chat.id
bot = context.bot
scheduler.add_job(message_loop, 'interval', minutes=5, args=(chat_id, bot))
scheduler.start()
# You might want to also add a stop function to your bot:
def stop():
scheduler.shutdown()
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(CommandHandler("stop", stop))
updater.start_polling()
you should try to add setinterval or a pure millis() function and you will be good to go

Create data source for Weblogic 12.2.1.3 in offline mode

I want to create Weblogic data source using WLST in offline mode and I'm getting error when I want to create Properties:
create('my_Prop','Properties')
Here is the entire script:
readDomain('C:\\weblogic12213\\user_projects\\domains\\myDomain')
cd('/')
create('myJDBC', 'JDBCSystemResource')
cd('/JDBCSystemResource/myJDBC')
set('Target','myApp')
cd('/JDBCSystemResource/myJDBC/JdbcResource/myJDBC')
cmo.setName('myJDBC')
create('myJDBC','JDBCDataSourceParams')
cd('JDBCDataSourceParams/myJDBC')
set('JNDIName', java.lang.String('jdbc.myJDBC'))
set('GlobalTransactionsProtocol', java.lang.String('OnePhaseCommit'))
cd('/JDBCSystemResource/myJDBC/JdbcResource/myJDBC')
create('myJDBC','JDBCDriverParams')
cd('JDBCDriverParams/myJDBC')
set('DriverName','weblogic.jdbc.sqlserver.SQLServerDriver')
set('URL','jdbc:weblogic:sqlserver://localhost:1433;allowPortWithNamedInstance=true')
set('PasswordEncrypted', 'myPassword')
set('UseXADataSourceInterface', 'false')
create('my_Prop','Properties')
cd('Properties/myJDBC')
create('user','Property')
cd('Property/user')
set('Value', 'myUser')
cd('/JDBCSystemResource/myJDBC/JdbcResource/myJDBC')
create('myJDBC','JDBCConnectionPoolParams')
cd('JDBCConnectionPoolParams/myJDBC')
set('TestTableName','SQL SELECT 1')
updateDomain()
closeDomain()
exit()
This error appears:
com.oracle.cie.domain.script.jython.WLSTException: Could not create generic operation:Properties
#com.oracle.cie.domain.operation.OperationBuilder.createConfigOperation(OperationBuilder.java:342)
at com.oracle.cie.domain.script.jython.CommandExceptionHandler.handleException(CommandExceptionHandler.java:69)
at com.oracle.cie.domain.script.jython.WLScriptContext.handleException(WLScriptContext.java:2983)
Does anybody have any idea please?
I suppose you already found the solution. This works for me without errors.
# cd into the already created driver params
cd('/JDBCSystemResource/myJDBC/JdbcResource/myJDBC/JDBCDriverParams/NO_NAME_0')
create('properties','Properties')
cd('Properties/NO_NAME_0')
create('property','Property')
cd('Property/property')
set("Key", "key")
set("Value", "value")
"""
This script configures a JDBC data source as a System Module and deploys it
to the server
"""
url='t3://' + sys.argv[1] + ':' + sys.argv[2]
username = sys.argv[3]
password = sys.argv[4]
connect(username,password,url)
edit()
# Change these names as necessary
dsname="myJDBCDataSource"
server=sys.argv[5]
cd("Servers/"+server)
target=cmo
cd("../..")
startEdit()
# start creation
print 'Creating JDBCSystemResource with name '+dsname
jdbcSR = create(dsname,"JDBCSystemResource")
theJDBCResource = jdbcSR.getJDBCResource()
theJDBCResource.setName("myJDBCDataSource")
connectionPoolParams = theJDBCResource.getJDBCConnectionPoolParams()
connectionPoolParams.setConnectionReserveTimeoutSeconds(25)
connectionPoolParams.setMaxCapacity(100)
connectionPoolParams.setTestTableName("SYSTABLES")
dsParams = theJDBCResource.getJDBCDataSourceParams()
dsParams.addJNDIName("ds.myJDBCDataSource")
driverParams = theJDBCResource.getJDBCDriverParams()
driverParams.setUrl("jdbc:derby://localhost:1527/examples;create=true")
driverParams.setDriverName("org.apache.derby.jdbc.ClientXADataSource")
# driverParams.setUrl("jdbc:oracle:thin:#my-oracle-server:my-oracle-server-port:my-oracle-sid")
# driverParams.setDriverName("oracle.jdbc.driver.OracleDriver")
driverParams.setPassword("examples")
# driverParams.setLoginDelaySeconds(60)
driverProperties = driverParams.getProperties()
proper = driverProperties.createProperty("user")
#proper.setName("user")
proper.setValue("examples")
proper1 = driverProperties.createProperty("DatabaseName")
#proper1.setName("DatabaseName")
proper1.setValue("examples")
jdbcSR.addTarget(target)
save()
activate(block="true")
print 'Done configuring the data source'`enter code here`

Freezing the time and date of an array of VMs

Is there a way to freeze the time and date of a VM, so that it is not synchronized with the guest BIOS and/or the internet? I have seen some solutions which talk about killing services inside the VM, but I wish to avoid this as it changes the "clean state" of the VM (used for testing purposes).
To clarify: I don't want to set the time offset for a VM, I want to set the exact time that will be passed to the OS at boot time.
From there, is there a way to do this across a large number of VMs?
Ended up solving the issue with a python script.
To use it, you edit the VM_NAMES list to contain the names of the VMs as they appear in VirtualBox, then set the RESET_TIME_VALUE according to the date and time you wish to send the VMs.
If you have installed VirtualBox in a non-default location, edit the VIRTUAL_BOX_MANAGE_PATH variable as well.
To run, call the main method.
import datetime
import subprocess
VIRTUAL_BOX_MANAGE_PATH = r"C:\Program Files\Oracle\VirtualBox\vboxmanage.exe"
SET_EXTRA_DATA_COMMAND = r"setextradata"
GET_HOST_TIME_DISABLE_COMMAND = "\"VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled\" \"1\""
MODIFY_VM_COMMAND = r"modifyvm"
BIOS_SYSTEM_TIME_OFFSET = r"--biossystemtimeoffset"
# Edit this list to add more Virtual Machines
VM_NAMES = ("xxx",
"yyy",
"zzz")
RESET_TIME_VALUE = datetime.datetime(2014, 6, 7, 13, 0, 0, 0)
def main():
for vm in VM_NAMES:
reset_time(vm)
disable_time_sync(vm)
def reset_time(vm_name):
"""
Resets the VM to the clean install time
"""
args = get_subprocess_args_set_bios_time(vm_name, RESET_TIME_VALUE)
print("Resetting time on VM [" + vm_name + "] to " + str(RESET_TIME_VALUE) + " ...")
subprocess.call(args)
print("\tDone.")
def disable_time_sync(vm_name):
"""
Disables the time synchronization of a VM with the BIOS
"""
args = [
VIRTUAL_BOX_MANAGE_PATH,
SET_EXTRA_DATA_COMMAND,
vm_name,
GET_HOST_TIME_DISABLE_COMMAND
]
print("Disabling time synchronization on VM [" + vm_name + "] ...")
subprocess.call(args)
print("\tDone.")
def get_subprocess_args_set_bios_time(vm_name, datetime_to_set):
"""
Returns a list containing the arguments to pass to the subprocess method
to start the Virtual Box Manage program and set the BIOS time to the supplied value
"""
return [
VIRTUAL_BOX_MANAGE_PATH,
MODIFY_VM_COMMAND,
vm_name,
BIOS_SYSTEM_TIME_OFFSET,
str(get_msec_time_difference(datetime.datetime.now(), datetime_to_set))
]
def get_msec_time_difference(reference_point, check_point):
"""
Computes the offset in msec from the reference point to the check point
"""
return int(round( (check_point - reference_point).total_seconds() * 1000 ))
" To run, call the main method."
..or just add at the end of the file
if __name__ == '__main__':
main()

How do I export PSDs as PNGs with py-appscript?

I wrote a script to export PSDs as PNGs with rb-appscript. That's fine and dandy, but I can't seem to pull it off in py-appscript.
Here's the ruby code:
#!/usr/bin/env ruby
require 'rubygems'
require 'optparse'
require 'appscript'
ps = Appscript.app('Adobe Photoshop CS5.app')
finder = Appscript.app("Finder.app")
path = "/Users/nbaker/Desktop/"
ps.activate
ps.open(MacTypes::Alias.path("#{path}guy.psd"))
layerSets = ps.current_document.layer_sets.get
# iterate through all layers and hide them
ps.current_document.layers.get.each do |layer|
layer.visible.set false
end
layerSets.each do |layerSet|
layerSet.visible.set false
end
# iterate through all layerSets, make them visible, and create a PNG for them
layerSets.each do |layerSet|
name = layerSet.name.get
layerSet.visible.set true
ps.current_document.get.export(:in => "#{path}#{name}.png", :as => :save_for_web,
:with_options => {:web_format => :PNG, :png_eight => false})
layerSet.visible.set false
end
And here's the apparently nonequivalent python code:
from appscript import *
from mactypes import *
# fire up photoshop
ps = app("Adobe Photoshop CS5.app")
ps.activate()
# open the file for editing
path = "/Users/nbaker/Desktop/"
f = Alias(path + "guy.psd")
ps.open(f)
layerSets = ps.current_document.layer_sets()
# iterate through all layers and hide them
for layer in ps.current_document.layers():
layer.visible.set(False)
#... and layerSets
for layerSet in layerSets:
layerSet.visible.set(False)
# iterate through all layerSets, make them visible, and create a PNG for them
for layerSet in layerSets:
name = layerSet.name()
layerSet.Visible = True
ps.current_document.get().export(in_=Alias(path + name + ".png"), as_=k.save_for_web,
with_options={"web_format":k.PNG, "png_eight":False})
The only part of the python script that doesn't work is the saving. I've gotten all sorts of errors trying different export options and stuff:
Connection is invalid... General Photoshop error occurred. This functionality may not be available in this version of Photoshop... Can't make some data into the expected type...
I can live with just the ruby script, but all of our other scripts are in python, so it would be nice to be able to pull this off in python. Thanks in advance internet.
Bert,
I think I have a solution for you – albeit several months later. Note that I'm a Python noob, so this is by no means elegant.
When I tried out your script, it kept crashing for me too. However by removing the "Alias" in the export call, it seems to be OK:
from appscript import *
from mactypes import *
# fire up photoshop
ps = app("Adobe Photoshop CS5.1.app")
ps.activate()
# open the file for editing
path = "/Users/ian/Desktop/"
f = Alias(path + "Screen Shot 2011-10-13 at 11.48.51 AM.psd")
ps.open(f)
layerSets = ps.current_document.layer_sets()
# no need to iterate
ps.current_document.layers.visible.set(False)
ps.current_document.layer_sets.visible.set(False)
# iterate through all layerSets, make them visible, and create a PNG for them
for l in layerSets:
name = l.name()
# print l.name()
l.visible.set(True)
# make its layers visible too
l.layers.visible.set(True)
# f = open(path + name + ".png", "w").close()
ps.current_document.get().export(in_=(path + name + ".png"), as_=k.save_for_web,
with_options={"web_format":k.PNG, "png_eight":False})
I noticed, too, that you iterate through all the layers to toggle their visibility. You can actually just issue them all a command at once – my understanding is that it's faster, since it doesn't have to keep issuing Apple Events.
The logic of my script isn't correct (with regards to turning layers on and off), but you get the idea.
Ian